Documentation

Python packages / tossd-reader / How-to guides

Measure Pillar II expenditures in the provider country

Filter a Pillar II frame to the sector-code carve-out for spending recorded inside the provider country, then calculate its share of total Pillar II disbursements.

Steps

  1. Query Pillar II with the "analysis" column preset. filter_provider_costs reads sector_code, which ships in the "analysis" preset. The "minimal" preset omits it.

    import tossd_reader as tossd
    
    p2 = tossd.get_tossd(years=2024, pillars=2, columns="analysis", units="usd_million")
    p2.shape
    
    (155908, 44)
    
  2. Filter to the provider-costs carve-out. The carve-out includes sector 910 ("Administrative Costs of Donors") and sector 930 ("Domestic expenditures for refugees/asylum seekers").

    pc = tossd.filter_provider_costs(p2)
    pc.groupby(["sector_code", "sector_name"], observed=True)[
        "usd_disbursement"
    ].sum().round(1)
    
    sector_code  sector_name
    910          Administrative Costs of Donors                       16826.6
    930          Domestic expenditures for refugees/asylum seekers    30677.2
    Name: usd_disbursement, dtype: float64
    
  3. Calculate the share of Pillar II disbursements.

    print(round(pc["usd_disbursement"].sum() / p2["usd_disbursement"].sum() * 100, 1))
    
    35.6
    

    Provider-country expenditures account for 47,503.8 of 133,561.8 USD million (35.6% of Pillar II in 2024). The five largest providers after removing aggregate rows are shown below.

    pc[~pc["is_aggregate"]].groupby("provider_name", observed=True)[
        "usd_disbursement"
    ].sum().sort_values(ascending=False).round(1).head(5)
    
    provider_name
    United States      14304.2
    United Kingdom      4524.2
    France              2261.5
    Canada              2073.7
    EU Institutions     2012.3
    Name: usd_disbursement, dtype: float64
    

Verify it worked

pc is a subset of p2 restricted to sectors 910 and 930.

len(pc) < len(p2), [int(c) for c in pc["sector_code"].unique()]
(True, [910, 930])

Troubleshooting

ValueError naming sector_code. filter_provider_costs requires sector_code on the input frame. That column ships in the "analysis" and "all" presets. The "minimal" preset omits it. Re-query with columns="analysis" or add "sector_code" to an explicit columns= list.

See also

View as markdown