Skip to content

Commit

Permalink
Fix duplicate rows in explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloarosado committed Feb 20, 2025
1 parent 2b8bab4 commit 1ba2dfb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions etl/steps/export/explorers/emissions/latest/air_pollution.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ def run(dest_dir: str) -> None:
df_graphers["Per capita Checkbox"] = per_capita_checkbox
df_graphers["hasMapTab"] = map_tab

# Sanity check.
error = "Duplicated rows in explorer."
assert df_graphers[
df_graphers.duplicated(subset=["Pollutant Dropdown", "Sector Dropdown", "Per capita Checkbox"], keep=False)
].empty, error

# Create view for all pollutants.
# Omit CH4 and N20 in this view.
for per_capita in [False, True]:
Expand Down Expand Up @@ -100,7 +94,7 @@ def run(dest_dir: str) -> None:
)

# Create breakdown by sector.
for pollutant, pollutant_short_name in zip(pollutant_dropdown, pollutant_short_names):
for pollutant, pollutant_short_name in list(dict.fromkeys(zip(pollutant_dropdown, pollutant_short_names))):
for per_capita in [False, True]:
_columns_for_pollutant = []
for column in tb.drop(columns=["country", "year"]).columns:
Expand Down Expand Up @@ -131,6 +125,12 @@ def run(dest_dir: str) -> None:
]
)

# Sanity check.
error = "Duplicated rows in explorer."
assert df_graphers[
df_graphers.duplicated(subset=["Pollutant Dropdown", "Sector Dropdown", "Per capita Checkbox"], keep=False)
].empty, error

# Impose that all line charts start at zero.
df_graphers["yAxisMin"] = 0

Expand Down

0 comments on commit 1ba2dfb

Please sign in to comment.