io¶
-
timeseries.io.
read_csv
(filepath, date_column='times', value_column='values', to_datetime=None, **kwargs)[source]¶ Read CSV file and return time series.
- Parameters
filepath – path of CSV file
date_column – date column string, defaults to ‘times’
value_column – value column string, defaults to ‘values’
to_datetime – date format string or explicit function for datetime conversion, defaults to days since UNIX epoch
**kwargs – optional keyword arguments passed to DictReader
- Example
>>> import timeseries as ts
>>> ts.read_csv(ts.samples_path + 'epoch.csv') date value 1970-01-01 00:00:00 1.00 1970-01-02 00:00:00 2.00 1970-01-03 00:00:00 3.00
>>> ts.read_csv(ts.samples_path + 'iso.csv', to_datetime='%Y-%m-%d') date value 1970-01-01 00:00:00 1.00 1970-01-02 00:00:00 2.00 1970-01-03 00:00:00 3.00
>>> ts.read_csv(ts.samples_path + 'epoch_semicolon.csv', delimiter=';') date value 1970-01-01 00:00:00 1.00 1970-01-02 00:00:00 2.00 1970-01-03 00:00:00 3.00
-
timeseries.io.
to_csv
(tseries, filepath, date_column='times', value_column='values', to_string=None, **kwargs)[source]¶ Write time series to CSV file.
- Parameters
tseries – time series object
filepath – path of output file
date_column – date column string, defaults to ‘times’
value_column – value column string, defaults to ‘values’
to_string – date format string or explicit function for string conversion, defaults to days since UNIX epoch
**kwargs – optional keyword arguments passed to DictWriter