diff --git a/_drivers-of-inequality-benin.qmd b/_drivers-of-inequality-benin.qmd index 6da54e8..fc5320b 100644 --- a/_drivers-of-inequality-benin.qmd +++ b/_drivers-of-inequality-benin.qmd @@ -210,8 +210,12 @@ totals = df.loc[ electricityaid = totals[totals['DONOR'] < 20000] # drop all 'total' aggregations el_grouped = electricityaid.groupby(['Year', 'Flow']).agg({'Value': ['sum']}) -el_grouped.style.format(escape="latex") -el_grouped +el_grouped = el_grouped.reset_index(['Year', 'Flow']) +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"}