Skip to content

Commit 2a5ed21

Browse files
committed
refactor: remove query calls which are incompatible with numexpr
1 parent 05f3ead commit 2a5ed21

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

prereise/gather/griddata/hifld/data_process/generators.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ def quadratic(x, a, b, c):
115115
try:
116116
epa_key = crosswalk_translation.loc[eia_key].values[0]
117117
samples = epa_ampd_groupby.get_group(epa_key)
118-
filtered_samples = samples.query(
119-
f"(not `{x_col}`.isnull()) and `{x_col}` != 0 "
120-
f"and (not `{y_col}`.isnull()) and `{y_col}` != 0"
121-
)
118+
filtered_samples = samples.loc[
119+
(samples[x_col] != 0)
120+
& (samples[y_col] != 0)
121+
& ~samples[x_col].isnull()
122+
& ~samples[y_col].isnull()
123+
]
122124
if len(filtered_samples[x_col].unique()) < min_unique_x:
123125
return default_return
124126
if len(filtered_samples) < min_points:
@@ -321,7 +323,7 @@ def build_plant(bus, substations, kwargs={}):
321323
filter_suspicious_heat_rates(generators)
322324
augment_missing_heat_rates(generators)
323325
# Drop generators whose heat rates can't be estimated
324-
to_be_dropped = generators.query("h1.isnull()")
326+
to_be_dropped = generators.loc[generators["h1"].isnull()]
325327
print(
326328
f"Dropping generators whose heat rates can't be estimated: {len(to_be_dropped)}"
327329
f" out of {len(generators)}, {round(to_be_dropped['Pmax'].sum(), 0)} MW out of "

prereise/gather/griddata/hifld/data_process/transmission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def map_via_neighbor_voltages(lines, neighbors, func, method_name):
408408
:param str method_name: method name to print once no more updates can be found.
409409
"""
410410
while True:
411-
missing = lines.query("VOLTAGE.isnull()")
411+
missing = lines.loc[lines["VOLTAGE"].isnull()]
412412
if len(missing) == 0:
413413
print(f"No more missing voltages remain after neighbor {method_name}")
414414
break

0 commit comments

Comments
 (0)