Skip to content

Commit

Permalink
Merge pull request #12 from JustinKurland/JustinKurland-pandas-pad-fix-1
Browse files Browse the repository at this point in the history
Update pad.py
  • Loading branch information
JustinKurland authored Oct 19, 2023
2 parents b5af115 + 3550606 commit 4b7b549
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pytimetk/core/pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ def pad_by_time(

padded_df.sort_values(by=[date_column], inplace=True)
padded_df.reset_index(drop=True, inplace=True)

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

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

return padded_df

Expand Down

0 comments on commit 4b7b549

Please sign in to comment.