tstoolbox.tstoolbox.createts

tstoolbox.tstoolbox.createts(freq=None, fillvalue=None, input_ts=None, index_type='datetime', start_date=None, end_date=None)

Create empty time series, optionally fill with a value.

Parameters
  • freq (str) –

    [optional, default is None]

    To use this form –start_date and –end_date must be supplied also. The freq option is the pandas date offset code used to create the index.

  • fillvalue

    [optional, default is None]

    The fill value for the time-series. The default is None, which generates the date/time stamps only.

  • input_ts (str) –

    [optional, required if using Python API, default is ‘-‘ (stdin)]

    Whether from a file or standard input, data requires a header of column names. The default header is the first line of the input, but this can be changed using the ‘skiprows’ option.

    Most separators will be automatically detected. Most common date formats can be used, but the closer to ISO 8601 date/time standard the better.

    Command line:

    +-------------------------+------------------------+
    | --input_ts=filename.csv | to read 'filename.csv' |
    +-------------------------+------------------------+
    | --input_ts='-'          | to read from standard  |
    |                         | input (stdin).         |
    +-------------------------+------------------------+
    
    In many cases it is better to use redirection rather that use
    `--input_ts=filename.csv`.  The following are identical:
    
    From a file:
    
        command subcmd --input_ts=filename.csv
    
    From standard input:
    
        command subcmd --input_ts=- < filename.csv
    
    The BEST way since you don't have to include `--input_ts=-` because
    that is the default:
    
        command subcmd < filename.csv
    
    Can also combine commands by piping:
    
        command subcmd < filename.csv | command subcmd1 > fileout.csv
    

    As Python Library:

    You MUST use the `input_ts=...` option where `input_ts` can be one
    of a [pandas DataFrame, pandas Series, dict, tuple,
    list, StringIO, or file name].
    
    If result is a time series, returns a pandas DataFrame.
    

  • 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.

  • 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.

  • 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’.