Skip to content

Commit

Permalink
Simplify end_dts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukhil Patel authored and Sukhil Patel committed Aug 14, 2024
1 parent 6d08e10 commit bded8db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ocf_data_sampler/select/fill_time_periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


def fill_time_periods(time_periods: pd.DataFrame, freq: pd.Timedelta):
start_dts = time_periods["start_dt"].apply(lambda x: pd.Timestamp(x).ceil(freq))
end_dts = time_periods['end_dt'].apply(lambda x: pd.Timestamp(x))
start_dts = pd.to_datetime(time_periods["start_dt"].values).ceil(freq)
end_dts = pd.to_datetime(time_periods['end_dt'])
date_ranges = [pd.date_range(start_dt, end_dt, freq=freq) for start_dt, end_dt in zip(start_dts, end_dts)]

return pd.DatetimeIndex(np.concatenate(date_ranges))

0 comments on commit bded8db

Please sign in to comment.