Skip to content

Commit

Permalink
Support processing of val_cond (#249)
Browse files Browse the repository at this point in the history
The support is partial and only in UPD and MIG tables.
  • Loading branch information
olejandro authored Nov 25, 2024
1 parent 6efc03f commit f05b54b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xl2times/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2392,6 +2392,7 @@ def query(
attribute: str | None,
region: str | None,
year: int | None,
val: int | float | None,
) -> pd.Index:
qs = []

Expand Down Expand Up @@ -2419,6 +2420,8 @@ def query(
qs.append(f"region == '{region}'")
if year not in [None, ""]:
qs.append(f"year == {year}")
if val not in [None, ""]:
qs.append(f"value == {val}")
query_str = " and ".join(qs)
row_idx = table.query(query_str).index
return row_idx
Expand Down Expand Up @@ -2464,6 +2467,7 @@ def apply_transform_tables(
row["attribute"],
row["region"],
row["year"],
row["val_cond"],
)

if not any(rows_to_update):
Expand Down Expand Up @@ -2507,7 +2511,7 @@ def apply_transform_tables(

# Query for rows with matching process/commodity and region
rows_to_update = query(
table, row["process"], row["commodity"], None, row["region"], None
table, row["process"], row["commodity"], None, row["region"], None, None
)
# Overwrite (inplace) the column given by the attribute (translated by attr_prop)
# with the value from row
Expand Down Expand Up @@ -2537,6 +2541,7 @@ def apply_transform_tables(
row["attribute"],
row["region"],
row["year"],
row["val_cond"],
)

if not any(rows_to_update):
Expand Down

0 comments on commit f05b54b

Please sign in to comment.