Fix crosstable for electrification in Benin

This commit is contained in:
Marty Oehme 2022-09-08 13:52:21 +02:00
parent f0c47afa84
commit 458e48cf26
Signed by: Marty
GPG key ID: B7538B8F50A1C800

View file

@ -210,8 +210,12 @@ totals = df.loc[
electricityaid = totals[totals['DONOR'] < 20000] # drop all 'total' aggregations electricityaid = totals[totals['DONOR'] < 20000] # drop all 'total' aggregations
el_grouped = electricityaid.groupby(['Year', 'Flow']).agg({'Value': ['sum']}) el_grouped = electricityaid.groupby(['Year', 'Flow']).agg({'Value': ['sum']})
el_grouped.style.format(escape="latex") el_grouped = el_grouped.reset_index(['Year', 'Flow'])
el_grouped el_grouped.columns = el_grouped.columns.to_flat_index()
el_grouped.columns = ['Year', 'Flow', 'Value']
crosstab = pd.crosstab(el_grouped['Year'], el_grouped['Flow'], margins=True, values=el_grouped['Value'], aggfunc='sum')
Markdown(tabulate(crosstab.fillna("0.00"), headers="keys", tablefmt="github", floatfmt=".2f"))
``` ```
::: {custom-style="caption"} ::: {custom-style="caption"}