Skip to content

Commit

Permalink
Merge pull request #77 from JustinKurland/JustinKurland-future-forwar…
Browse files Browse the repository at this point in the history
…d-fill-internal

Update future.py forward fill internal
  • Loading branch information
JustinKurland committed Nov 1, 2023
2 parents b3e4739 + 1bf9732 commit 3f6c744
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/pytimetk/core/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def future_frame(
date_column = 'date',
length_out = 12
)
.assign(id = lambda x: x['id'].ffill())
)
extended_df
```
Expand Down Expand Up @@ -241,7 +240,16 @@ def _future_frame_pandas(
extended_df = pd.concat([data, new_rows], axis=0, ignore_index=True)
else:
extended_df = new_rows


col_name = extended_df.columns[extended_df.nunique() == 1]
if not col_name.empty:
col_name = col_name[0]
else:
col_name = None

if col_name is not None:
extended_df = extended_df.assign(**{f'{col_name}': extended_df[col_name].ffill()})

return extended_df

# If the data is grouped
Expand Down

0 comments on commit 3f6c744

Please sign in to comment.