Skip to content

Commit

Permalink
Merge branch 'main' into 2.1-negative-net-flows
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattie-P committed Apr 15, 2024
2 parents a20f80c + 387f576 commit bb155a9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 25 deletions.
21 changes: 9 additions & 12 deletions output/chart_1_1.csv
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Developing countries,2019,100848423070.40002,
Developing countries,2020,149424205779.19998,
Developing countries,2021,98510059099.00002,
Developing countries,2022,51406101384.2,51406101384.2
Developing countries,2023,,-21548519402.333374
Developing countries,2024,,-50546702741.11678
Developing countries,2025,,-17922724633.3993
Developing countries,2023,,-21444458971.533375
Developing countries,2024,,-50474427554.61678
Developing countries,2025,,-17865922210.3993
Low income,2000,6979069145.5,
Low income,2001,7502707071.3,
Low income,2002,9938232026.2,
Expand All @@ -48,9 +48,9 @@ Low income,2019,44556702957.6,
Low income,2020,50183722528.6,
Low income,2021,36622590659.5,
Low income,2022,34587927336.2,34587927336.2
Low income,2023,,28364363722.266666
Low income,2024,,24804158358.683304
Low income,2025,,26513277885.06658
Low income,2023,,28468424153.066666
Low income,2024,,24876433545.183304
Low income,2025,,26570080308.06658
Lower middle income,2000,1824424208.5999997,
Lower middle income,2001,828924233.7999996,
Lower middle income,2002,2703727390.7,
Expand Down Expand Up @@ -178,9 +178,9 @@ Asia,2019,66046812230.69999,
Asia,2020,51207209621.799995,
Asia,2021,45631011042.700005,
Asia,2022,7886931731.300001,7886931731.300001
Asia,2023,,-11099918754.599985
Asia,2024,,-36763162600.30055
Asia,2025,,-18345542017.09953
Asia,2023,,-10995858323.799984
Asia,2024,,-36690887413.80055
Asia,2025,,-18288739594.09953
Afghanistan,2006,2992784946.2,
Afghanistan,2007,4594938120.6,
Afghanistan,2008,4702888058.6,
Expand Down Expand Up @@ -2816,9 +2816,6 @@ Syria,2017,10417863675.5,
Syria,2018,10015404769.7,
Syria,2019,10132758298.6,
Syria,2020,10040737648.5,
Syria,2023,,-104060430.8
Syria,2024,,-72275186.5
Syria,2025,,-56802423.0
Tajikistan,2000,84554859.9,
Tajikistan,2001,127627186.1,
Tajikistan,2002,146203549.2,
Expand Down
Binary file modified output/inflows_outflows_projected_country.parquet
Binary file not shown.
22 changes: 11 additions & 11 deletions output/key_numbers.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
"dev_countries_nt_latest_value": "$51.41 bn",
"dev_countries_nt_change_2021_2022_value": "$-47.104 bn",
"dev_countries_nt_change_2021_2022_percentage": "-47.8%",
"dev_countries_nt_2024": "$-50.547 bn",
"dev_countries_nt_2022_2024_change": "$-101.96 bn",
"dev_countries_nt_2022_2024_change_pct": "-198.3%",
"dev_countries_nt_2024": "$-50.474 bn",
"dev_countries_nt_2022_2024_change": "$-101.88 bn",
"dev_countries_nt_2022_2024_change_pct": "-198.2%",
"umic_nt_2021_value": "$-8.29 bn",
"umic_nt_population": "905 million",
"lmic_nt_2024_value": "$-29.83 bn",
"lmic_nt_population": "3.4 billion",
"nnt_count_2022": "26 out of 118 countries",
"nnt_countries_total_value_2022": "$-47.89 bn",
"nnt_2022_countries_population": "1299 million",
"nnt_count_2023": "39 out of 119 countries",
"nnt_countries_total_value_2023": "$-101.42 bn",
"nnt_count_2024": "41 out of 119 countries",
"nnt_countries_total_value_2024": "$-124.67 bn",
"nnt_count_2025": "45 out of 119 countries",
"nnt_countries_total_value_2025": "$-101.82 bn",
"nnt_count_2023": "38 out of 118 countries",
"nnt_countries_total_value_2023": "$-101.31 bn",
"nnt_count_2024": "40 out of 118 countries",
"nnt_countries_total_value_2024": "$-124.59 bn",
"nnt_count_2025": "44 out of 118 countries",
"nnt_countries_total_value_2025": "$-101.76 bn",
"dev_countries_debt_service_2022": "$-293.66 bn",
"dev_countries_debt_service_projected_2023": "$-346.62 bn",
"dev_countries_debt_service_projected_2024": "$-358.44 bn",
"dev_countries_debt_service_projected_2023": "$-346.52 bn",
"dev_countries_debt_service_projected_2024": "$-358.37 bn",
"china_lending_africa_average_2008_2021": "$8.9 bn",
"china_lending_africa_2022": "$6.3 bn",
"china_lending_africa_peak_year": 2016,
Expand Down
Binary file modified output/net_flow_projections_country.parquet
Binary file not shown.
Binary file modified output/net_flow_projections_group.parquet
Binary file not shown.
29 changes: 27 additions & 2 deletions scripts/analysis/net_flow_projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,34 @@ def projected_netflows(inflows: pd.DataFrame, outflows: pd.DataFrame) -> pd.Data
index=[c for c in data.columns if c not in ["value", "indicator_type"]],
columns="indicator_type",
values="value",
)
).reset_index()
# .fillna(0)
)

# Create grouped data at right level to check missing projections.
missing_projections_groups = data.loc[lambda d: d.year > 2022].groupby(
["year", "country", "continent", "income_level"], dropna=False
)

# Check if inflow is missing for all values in group
missing_projections = (
missing_projections_groups["inflow"]
.apply(lambda x: x.isnull().all())
.reset_index()
.fillna(0)
.filter(["year", "country", "inflow"])
)

# Merge missing projections back to data. Remove missing inflow projections
data = (
pd.merge(
data,
missing_projections,
on=["year", "country"],
how="left",
suffixes=("", "_m"),
)
.loc[lambda d: d.inflow_m != True]
.drop(columns=["inflow_m"])
)

# Group by country
Expand Down

0 comments on commit bb155a9

Please sign in to comment.