tstoolbox.tstoolbox.read

tstoolbox.tstoolbox.read(filenames, force_freq=None, append='columns', columns=None, start_date=None, end_date=None, dropna='no', skiprows=None, index_type='datetime', names=None, clean=False, source_units=None, target_units=None, round_index=None)

Collect time series from a list of pickle or csv files.

Prints the read in time-series in the tstoolbox standard format.

Parameters
  • filenames (str) – List of comma delimited filenames to read time series from.

  • append (str) –

    [optional, default is ‘columns’]

    The type of appending to do. For “combine” option matching column indices will append rows, matching row indices will append columns, and matching column/row indices use the value from the first dataset. You can use “row” or “column” to force an append along either axis.

  • force_freq (str) –

    [optional, output format]

    Force this frequency for the files. Typically you will only want to enforce a smaller interval where tstoolbox will insert missing values as needed. WARNING: you may lose data if not careful with this option. In general, letting the algorithm determine the frequency should always work, but this option will override. Use PANDAS offset codes.

    Alias

    Description

    B

    business day

    C

    custom business day (experimental)

    D

    calendar day

    W

    weekly

    M

    month end

    BM

    business month end

    CBM

    custom business month end

    MS

    month start

    BMS

    business month start

    CBMS

    custom business month start

    Q

    quarter end

    BQ

    business quarter end

    QS

    quarter start

    BQS

    business quarter start

    A

    year end

    BA

    business year end

    AS

    year start

    BAS

    business year start

    H

    hourly

    T

    minutely

    S

    secondly

    L

    milliseconds

    U

    microseconds

    N

    nanoseconds

    Weekly has the following anchored frequencies:

    Alias

    Description

    W-SUN

    weekly frequency (sundays). Same as ‘W’.

    W-MON

    weekly frequency (mondays)

    W-TUE

    weekly frequency (tuesdays)

    W-WED

    weekly frequency (wednesdays)

    W-THU

    weekly frequency (thursdays)

    W-FRI

    weekly frequency (fridays)

    W-SAT

    weekly frequency (saturdays)

    Quarterly frequencies (Q, BQ, QS, BQS) and annual frequencies (A, BA, AS, BAS) have the following anchoring suffixes:

    Alias

    Description

    -DEC

    year ends in December (same as ‘Q’ and ‘A’)

    -JAN

    year ends in January

    -FEB

    year ends in February

    -MAR

    year ends in March

    -APR

    year ends in April

    -MAY

    year ends in May

    -JUN

    year ends in June

    -JUL

    year ends in July

    -AUG

    year ends in August

    -SEP

    year ends in September

    -OCT

    year ends in October

    -NOV

    year ends in November

  • columns

    [optional, defaults to all columns, input filter]

    Columns to select out of input. Can use column names from the first line header or column numbers. If using numbers, column number 1 is the first data column. To pick multiple columns; separate by commas with no spaces. As used in tstoolbox pick command.

    This solves a big problem so that you don’t have to create a data set with a certain order, you can rearrange columns when data is read in.

  • start_date (str) –

    [optional, defaults to first date in time-series, input filter]

    The start_date of the series in ISOdatetime format, or ‘None’ for beginning.

  • end_date (str) –

    [optional, defaults to last date in time-series, input filter]

    The end_date of the series in ISOdatetime format, or ‘None’ for end.

  • dropna (str) –

    [optional, defauls it ‘no’, input filter]

    Set dropna to ‘any’ to have records dropped that have NA value in any column, or ‘all’ to have records dropped that have NA in all columns. Set to ‘no’ to not drop any records. The default is ‘no’.

  • skiprows (list-like or integer or callable) –

    [optional, default is None which will infer header from first line, input filter]

    Line numbers to skip (0-indexed) or number of lines to skip (int) at the start of the file.

    If callable, the callable function will be evaluated against the row indices, returning True if the row should be skipped and False otherwise. An example of a valid callable argument would be

    lambda x: x in [0, 2].

  • index_type (str) –

    [optional, default is ‘datetime’, output format]

    Can be either ‘number’ or ‘datetime’. Use ‘number’ with index values that are Julian dates, or other epoch reference.

  • names

    [optional, default is None, input filter]

    If None, the column names are taken from the first row after ‘skiprows’ from the input dataset.

  • clean

    [optional, default is False, input filter]

    The ‘clean’ command will repair an index, removing duplicate index values and sorting.

  • source_units

    [optional, default is None, transformation]

    If unit is specified for the column as the second field of a ‘:’ delimited column name, then the specified units and the ‘source_units’ must match exactly.

    Any unit string compatible with the ‘pint’ library can be used.

  • target_units

    [optional, default is None, transformation]

    The main purpose of this option is to convert units from those specified in the header line of the input into ‘target_units’.

    The units of the input time-series or values are specified as the second field of a ‘:’ delimited name in the header line of the input or in the ‘source_units’ keyword.

    Any unit string compatible with the ‘pint’ library can be used.

    This option will also add the ‘target_units’ string to the column names.

  • float_format

    [optional, output format]

    Format for float numbers.

  • round_index

    [optional, default is None which will do nothing to the index, output format]

    Round the index to the nearest time point. Can significantly improve the performance since can cut down on memory and processing requirements, however be cautious about rounding to a very course interval from a small one. This could lead to duplicate values in the index.

  • tablefmt (str) –

    [optional, default is ‘csv’, output format]

    The table format. Can be one of ‘csv’, ‘tsv’, ‘plain’, ‘simple’, ‘grid’, ‘pipe’, ‘orgtbl’, ‘rst’, ‘mediawiki’, ‘latex’, ‘latex_raw’ and ‘latex_booktabs’.