Skip to content

Commit

Permalink
Merge pull request #33 from ONEcampaign/ghed_bug
Browse files Browse the repository at this point in the history
Ghed bug
  • Loading branch information
lpicci96 authored Dec 6, 2024
2 parents 520e77f + b7df560 commit c6114a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/bblocks_data_importers/who/ghed.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def _format_main_data(self) -> pd.DataFrame:
return (
pd.read_excel(self._raw_data, sheet_name="Data", dtype_backend="pyarrow")
.drop(columns=["region", "income"])
.melt(id_vars=["country", "code", "year"], var_name="indicator_code")
.rename(columns={"country": Fields.country_name, "code": Fields.iso3_code})
.melt(id_vars=["location", "code", "year"], var_name="indicator_code")
.rename(columns={"location": Fields.country_name, "code": Fields.iso3_code})
.pipe(convert_dtypes)
)

Expand Down Expand Up @@ -189,15 +189,15 @@ def _format_metadata(self) -> pd.DataFrame:
"""

cols = {
"country": Fields.country_name,
"location": Fields.country_name,
"code": Fields.iso3_code,
"variable name": Fields.indicator_name,
"variable code": Fields.indicator_code,
"Sources": "sources",
"Comments": "comments",
"Data type": "data_type",
"Methods of estimation": "methods_of_estimation",
"Country footnote": "country_footnote",
"Countries and territories footnote": "country_footnote",
}

try:
Expand Down
Binary file modified tests/test_data/test_ghed.XLSX
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_who/test_ghed.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_format_data_missing_columns(mock_raw_data):

# format the raw data to remove a required column
raw_df = pd.read_excel(mock_raw_data, sheet_name="Data")
raw_df.drop(columns=["country"], inplace=True)
raw_df.drop(columns=["location"], inplace=True)
modified_raw_data = io.BytesIO()
with pd.ExcelWriter(modified_raw_data, engine="xlsxwriter") as writer:
raw_df.to_excel(writer, sheet_name="Data")
Expand Down

0 comments on commit c6114a5

Please sign in to comment.