Skip to content

Commit 8f97bff

Browse files
failproof
1 parent c66a9e9 commit 8f97bff

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

cybench/datasets/configured.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ def load_dfs(
134134
dfs_x = {"soil": df_x_soil}
135135

136136
# location
137-
df_x_location = pd.read_csv(
138-
os.path.join(path_data_cn, "_".join(["location", crop, country_code]) + ".csv"),
139-
header=0,
140-
)
141-
df_x_location = df_x_location[[KEY_LOC] + LOCATION_PROPERTIES]
142-
df_x_location.set_index([KEY_LOC], inplace=True)
137+
if LOCATION_PROPERTIES:
138+
df_x_location = pd.read_csv(
139+
os.path.join(
140+
path_data_cn, "_".join(["location", crop, country_code]) + ".csv"
141+
),
142+
header=0,
143+
)
144+
df_x_location = df_x_location[[KEY_LOC] + LOCATION_PROPERTIES]
145+
df_x_location.set_index([KEY_LOC], inplace=True)
143146

144-
dfs_x["location"] = df_x_location
147+
dfs_x["location"] = df_x_location
145148

146149
# crop calendar
147150
df_crop_cal = pd.read_csv(

cybench/models/sklearn_models.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,14 @@ def _design_features(self, crop: str, data_items: Iterable):
197197
soil_df = data_to_pandas(data_items, data_cols=[KEY_LOC] + SOIL_PROPERTIES)
198198
soil_df = soil_df.drop_duplicates()
199199

200-
location_df = data_to_pandas(
201-
data_items, data_cols=[KEY_LOC] + LOCATION_PROPERTIES
202-
)
203-
location_df = location_df.drop_duplicates()
200+
dfs_x = {"soil": soil_df}
204201

205-
dfs_x = {"soil": soil_df, "location": location_df}
202+
if LOCATION_PROPERTIES:
203+
location_df = data_to_pandas(
204+
data_items, data_cols=[KEY_LOC] + LOCATION_PROPERTIES
205+
)
206+
location_df = location_df.drop_duplicates()
207+
dfs_x["location"] = location_df
206208

207209
for x, ts_cols in TIME_SERIES_INPUTS.items():
208210
df_ts = data_to_pandas(

0 commit comments

Comments
 (0)