TimeSeriesDataFrame.to_regular_index#
- TimeSeriesDataFrame.to_regular_index(freq: str) TimeSeriesDataFrame [source]#
Fill the gaps in an irregularly-sampled time series with NaNs.
- Parameters
freq (str) – Frequency string of the new time series data index.
Examples
>>> print(ts_dataframe) target item_id timestamp 0 2019-01-01 NaN 2019-01-03 1.0 2019-01-06 2.0 2019-01-07 NaN 1 2019-02-04 3.0 2019-02-07 4.0
>>> print(ts_dataframe.to_regular_index(freq="D")) target item_id timestamp 0 2019-01-01 NaN 2019-01-02 NaN 2019-01-03 1.0 2019-01-04 NaN 2019-01-05 NaN 2019-01-06 2.0 2019-01-07 NaN 1 2019-02-04 3.0 2019-02-05 NaN 2019-02-06 NaN 2019-02-07 4.0