Skip to content

Commit

Permalink
refactor: remove query calls which are incompatible with numexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Mar 14, 2022
1 parent 86a61d7 commit 851098e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions prereise/gather/griddata/hifld/data_process/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ def quadratic(x, a, b, c):
try:
epa_key = crosswalk_translation.loc[eia_key].values[0]
samples = epa_ampd_groupby.get_group(epa_key)
filtered_samples = samples.query(
f"(not `{x_col}`.isnull()) and `{x_col}` != 0 "
f"and (not `{y_col}`.isnull()) and `{y_col}` != 0"
)
filtered_samples = samples.loc[
(samples[x_col] != 0)
& (samples[y_col] != 0)
& ~samples[x_col].isnull()
& ~samples[y_col].isnull()
]
if len(filtered_samples[x_col].unique()) < min_unique_x:
return default_return
if len(filtered_samples) < min_points:
Expand Down Expand Up @@ -321,7 +323,7 @@ def build_plant(bus, substations, kwargs={}):
filter_suspicious_heat_rates(generators)
augment_missing_heat_rates(generators)
# Drop generators whose heat rates can't be estimated
to_be_dropped = generators.query("h1.isnull()")
to_be_dropped = generators.loc[generators["h1"].isnull()]
print(
f"Dropping generators whose heat rates can't be estimated: {len(to_be_dropped)}"
f" out of {len(generators)}, {round(to_be_dropped['Pmax'].sum(), 0)} MW out of "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def map_via_neighbor_voltages(lines, neighbors, func, method_name):
:param str method_name: method name to print once no more updates can be found.
"""
while True:
missing = lines.query("VOLTAGE.isnull()")
missing = lines.loc[lines["VOLTAGE"].isnull()]
if len(missing) == 0:
print(f"No more missing voltages remain after neighbor {method_name}")
break
Expand Down

0 comments on commit 851098e

Please sign in to comment.