Bug fix: if df has no rows write an empty zscore file.

sociality-task
Primoz 2022-07-08 10:40:45 +00:00
parent 21eb2665d7
commit 788ac31190
1 changed files with 13 additions and 10 deletions

View File

@ -21,17 +21,20 @@ if provider_key == "cr":
windows_features_data = pd.read_csv(sensor_data_files["windows_features_data"]) windows_features_data = pd.read_csv(sensor_data_files["windows_features_data"])
excluded_columns = ['local_segment', 'local_segment_label', 'local_segment_start_datetime', 'local_segment_end_datetime', prefix + "level_1"] excluded_columns = ['local_segment', 'local_segment_label', 'local_segment_start_datetime', 'local_segment_end_datetime', prefix + "level_1"]
windows_features_data.loc[:, ~windows_features_data.columns.isin(excluded_columns)] = \
StandardScaler().fit_transform(windows_features_data.loc[:, ~windows_features_data.columns.isin(excluded_columns)]) if windows_features_data.empty:
windows_features_data.to_csv(snakemake.output[1], index=False)
windows_features_data.to_csv(snakemake.output[1], index=False) windows_features_data.to_csv(snakemake.output[0], index=False)
if provider_main["WINDOWS"]["COMPUTE"] and "SECOND_ORDER_FEATURES" in provider_main["WINDOWS"]:
so_features_names = provider_main["WINDOWS"]["SECOND_ORDER_FEATURES"]
windows_so_features_data = extract_second_order_features(windows_features_data, so_features_names, prefix)
windows_so_features_data.to_csv(snakemake.output[0], index=False)
else: else:
pd.DataFrame().to_csv(snakemake.output[0], index=False) windows_features_data.loc[:, ~windows_features_data.columns.isin(excluded_columns)] = \
StandardScaler().fit_transform(windows_features_data.loc[:, ~windows_features_data.columns.isin(excluded_columns)])
windows_features_data.to_csv(snakemake.output[1], index=False)
if provider_main["WINDOWS"]["COMPUTE"] and "SECOND_ORDER_FEATURES" in provider_main["WINDOWS"]:
so_features_names = provider_main["WINDOWS"]["SECOND_ORDER_FEATURES"]
windows_so_features_data = extract_second_order_features(windows_features_data, so_features_names, prefix)
windows_so_features_data.to_csv(snakemake.output[0], index=False)
else: else:
pass #To-Do for the rest of the sensors. pass #To-Do for the rest of the sensors.