@@ -567,6 +567,12 @@ Using `pandas` we can take a quick look across all countries and all years in th
567
567
By leaving off the ` "USA" ` this function returns all Gini data that is available.
568
568
569
569
``` {code-cell} ipython3
570
+ ---
571
+ mystnb:
572
+ figure:
573
+ caption: Histogram of Gini coefficients
574
+ name: gini_histogram
575
+ ---
570
576
# Fetch gini data for all countries
571
577
gini_all = wb.data.DataFrame("SI.POV.GINI")
572
578
gini_all.columns = gini_all.columns.map(lambda x: int(x.replace('YR',''))) # remove 'YR' in index and convert to int
@@ -588,6 +594,12 @@ We can see that across 50 years of data and all countries (including low and hig
588
594
Let us zoom on the US data so we can more clearly observe trends.
589
595
590
596
``` {code-cell} ipython3
597
+ ---
598
+ mystnb:
599
+ figure:
600
+ caption: Gini coefficients (USA)
601
+ name: gini_usa_trend
602
+ ---
591
603
fig, ax = plt.subplots()
592
604
ax = data_usa.plot(ax=ax)
593
605
ax.set_ylim(data_usa.min()-1, data_usa.max()+1)
@@ -740,6 +752,12 @@ There are 167 countries represented in this dataset.
740
752
Let us compare three western economies: USA, United Kingdom, and Norway
741
753
742
754
``` {code-cell} ipython3
755
+ ---
756
+ mystnb:
757
+ figure:
758
+ caption: Gini coefficients (USA, United Kingdom, and Norway)
759
+ name: gini_usa_gbr_nor1
760
+ ---
743
761
ax = data[['USA','GBR', 'NOR']].plot()
744
762
ax.set_xlabel('year')
745
763
ax.set_ylabel('Gini coefficient')
@@ -758,6 +776,12 @@ The data for Norway in this dataset goes back to 1979 but there are gaps in the
758
776
We can use the ` .ffill() ` method to copy and bring forward the last known value in a series to fill in these gaps
759
777
760
778
``` {code-cell} ipython3
779
+ ---
780
+ mystnb:
781
+ figure:
782
+ caption: Gini coefficients (USA, United Kingdom, and Norway)
783
+ name: gini_usa_gbr_nor2
784
+ ---
761
785
data['NOR'] = data['NOR'].ffill()
762
786
ax = data[['USA','GBR', 'NOR']].plot()
763
787
ax.set_xlabel('year')
@@ -820,6 +844,12 @@ plot_data.year = plot_data.year.map(lambda x: x if x in labels else None)
820
844
(fig: plotly-gini-gdppc-years )=
821
845
822
846
``` {code-cell} ipython3
847
+ ---
848
+ mystnb:
849
+ figure:
850
+ caption: Gini coefficients and GDP per capita (USA, United Kingdom, and Norway)
851
+ name: gini_gdppc_usa_gbr_nor1
852
+ ---
823
853
fig = px.line(plot_data,
824
854
x = "gini",
825
855
y = "gdppc",
@@ -928,8 +958,6 @@ mystnb:
928
958
figure:
929
959
caption: US top shares
930
960
name: top_shares_us
931
- image:
932
- alt: top_shares_us
933
961
---
934
962
fig, ax = plt.subplots()
935
963
ax.plot(years, df_topshares["topshare_l_income"],
0 commit comments