Fix bug of sleep intraday PRICE provider when the dataframe of a segment is empty

pull/130/head
Meng Li 2021-03-17 15:21:31 -04:00
parent 7e919eaaeb
commit 294d84277d
1 changed files with 3 additions and 3 deletions

View File

@ -181,12 +181,12 @@ def price_features(sensor_data_files, time_segment, provider, filter_data_by_seg
features_fullnames = featuresFullNames(intraday_features_to_compute, sleep_levels_to_compute, day_types_to_compute)
sleep_intraday_features = pd.DataFrame(columns=features_fullnames)
if sleep_intraday_data.empty:
return sleep_intraday_features
# Filter by segemnts and chunk episodes
sleep_intraday_data = filter_data_by_segment(sleep_intraday_data, time_segment)
if sleep_intraday_data.empty:
return sleep_intraday_features
# Discard segments shorter than one day
sleep_intraday_data["segment_length"] = (sleep_intraday_data["segment_end_timestamp"] - sleep_intraday_data["segment_start_timestamp"]) / 1000 # in seconds
sleep_intraday_data = sleep_intraday_data[sleep_intraday_data["segment_length"] >= 24 * 60 * 60 - 1]