Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "id" parameter for make_forecaseting_frame so that it will not … #1080

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tsfresh/utilities/dataframe_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def roll_time_series(
return df_shift.sort_values(by=["id", column_sort or "sort"])


def make_forecasting_frame(x, kind, max_timeshift, rolling_direction):
def make_forecasting_frame(x, id, kind, max_timeshift, rolling_direction):
"""
Takes a singular time series x and constructs a DataFrame df and target vector y that can be used for a time series
forecasting task.
Expand All @@ -597,6 +597,8 @@ def make_forecasting_frame(x, kind, max_timeshift, rolling_direction):

:param x: the singular time series
:type x: np.array or pd.Series
:param id: the id for the time series
:type id: str
:param kind: the kind of the time series
:type kind: str
:param rolling_direction: The sign decides, if to roll backwards (if sign is positive) or forwards in "time"
Expand All @@ -614,7 +616,7 @@ def make_forecasting_frame(x, kind, max_timeshift, rolling_direction):
else:
t = range(n)

df = pd.DataFrame({"id": ["id"] * n, "time": t, "value": x, "kind": kind})
df = pd.DataFrame({"id": id, "time": t, "value": x, "kind": kind})

df_shift = roll_time_series(
df,
Expand Down Expand Up @@ -644,7 +646,7 @@ def mask_first(x):

# make sure that the format is the same as the
# df_shift index
y.index = map(lambda x: ("id", x), y.index)
y.index = map(lambda x: (id, x), y.index)

return df_shift, y

Expand Down