olaf.utils.data_handler¶
Classes¶
Module Contents¶
- class olaf.utils.data_handler.DataHandler(folder_path, num_samples, **kwargs)¶
- Parameters:
folder_path (pathlib.Path)
num_samples (int)
- folder_path¶
- num_samples¶
- get_data_file(includes, excludes, suffix='.dat', date_col='Time', sep='\t')¶
Load a file with a given suffix (default: .dat) from the Project folder. Arguments to exclude files can be passed as a list to the “excludes” parameter. Because of pandas loading, the Date and Time in column “Time” are split in two Different columns and renamed to Date and Time respectively. It also adds a column to capture changes to the number of frozen wells. The function returns the file path and the data as a pandas DataFrame. :param suffix: suffix of the file to load (default: .dat) :param includes: combination of strings to include in the file name (default: None) :param excludes: combination of strings to exclude from the file name (default: None) :param date_col: column name for the date (or time) column (default: “Time”) :param sep: separator for the file to load (default: tab-separated)
- Returns:
tuple with the file path and the data as a pandas DataFrame
- Parameters:
includes (tuple)
excludes (tuple)
suffix (str)
date_col (str)
sep (str)
- Return type:
tuple[pathlib.Path, pandas.DataFrame]
- save_to_new_file(save_data=None, save_path=None, prefix='_', sep=',', header=None)¶
Save a DataFrame to a new file with a unique name.
If the target file already exists, automatically adds a number suffix to create a unique filename.
- Parameters:
save_data (pandas.DataFrame | None) – Pandas DataFrame to save. If None, uses self.data
save_path (pathlib.Path | None) – Path to save the file to. If None, uses self.data_file
prefix (str) – String to add to the start of the file name
sep (str) – Separator for CSV file (default: comma)
header (str | None) – Header to add to the file. If None, no header is added
- Returns:
Path to the saved file
- Return type:
Path
- Raises:
ValueError – If save_data is None and self.data is not available
TypeError – If save_path is not a Path object
OSError – If there are file system related errors