Files
pytorch-ts/pts/dataset/utils.py
T
Kashif Rasul 4ad01ea2e3 ran isort
isort --recursive --atomic --apply pts
2019-10-30 09:38:19 +01:00

27 lines
656 B
Python

import pandas as pd
def to_pandas(instance: dict, freq: str = None) -> pd.Series:
"""
Transform a dictionary into a pandas.Series object, using its
"start" and "target" fields.
Parameters
----------
instance
Dictionary containing the time series data.
freq
Frequency to use in the pandas.Series index.
Returns
-------
pandas.Series
Pandas time series object.
"""
target = instance["target"]
start = instance["start"]
if not freq:
freq = start.freqstr
index = pd.date_range(start=start, periods=len(target), freq=freq)
return pd.Series(target, index=index)