maui.io.store_df

maui.io.store_df(df, file_type, base_dir, file_name)[source]

Store a DataFrame to a file in a specified format.

This function takes a DataFrame ‘df’ and saves it to a file in the specified ‘file_type’ and location, combining ‘base_dir’ and ‘file_name’.

Parameters:
df: pandas.DataFrame

The DataFrame to be saved.

file_type: str

The file format to use for storing the DataFrame (‘csv’ or ‘pickle’).

base_dir: str

The base directory where the file will be saved.

file_name: str

The name of the file (without file extension).

Returns:
None

Examples

>>> from maui import io
>>> data = {'A': [1, 2, 3], 'B': ['a', 'b', 'c']}
>>> df = pd.DataFrame(data)
>>> io.store_df(df, 'csv', '/path/to/directory', 'my_dataframe')
# Saves the DataFrame as '/path/to/directory/my_dataframe.csv'
>>> io.store_df(df, 'pickle', '/path/to/directory', 'my_dataframe')
# Saves the DataFrame as '/path/to/directory/my_dataframe.pkl'