bulum.io.csv_io module
Functions for reading CSVs, particularly time-series CSVs.
- read_ts_csv(filename: str | PathLike, date_format=None, df=None, colprefix=None, allow_nonnumeric=False, assert_date=True, **kwargs) TimeseriesDataframe
Reads a daily timeseries csv into a DataFrame, and sets the index to string dates in the “%Y-%m-%d” format. The method assumes the first column are dates.
- Parameters:
filename (str | PathLike)
date_format (str, optional) – defaults to “%d/%m/%Y” as per Fors. Other common formats include “%Y-%m-%d”, “%Y/%m/%d”.
df (pd.DataFrame, optional) – If provided, the reader will append columns to this dataframe. Defaults to None.
colprefix (str, optional) – If provided, the reader will append this prefix to the start of each column name. Defaults to None.
allow_nonnumeric (bool, optional) – If false, the method will assert that all columns are numerical. Defaults to False.
assert_date (bool, optional) – If true, the method will assert that date index meets “%Y-%m-%d” format. Defaults to True.
Returns – pd.DataFrame: Dataframe containing the data from the csv file.