def round_timestamp_to_sleep_date(timeseries):
"""
Not my proudest function ... this isn't as efficient as it could be, but struggling
with some pandas syntax to find the perfect pandas one-line
This can be much more performant, but need time to sit down and figure it out
"""
sleep_dates = []
for value in timeseries:
if value.hour < SLEEP_CUTOFF_TIME:
result = value - pd.DateOffset(days=1)
else:
result = value
sleep_dates.append(result)
index = pd.DatetimeIndex(sleep_dates)
return index
评论列表
文章目录