@@ -247,7 +247,7 @@ The following code block imports a subset of the dataset `SCF_plus` for 2016,
247
247
which is derived from the [ Survey of Consumer Finances] ( https://en.wikipedia.org/wiki/Survey_of_Consumer_Finances ) (SCF).
248
248
249
249
``` {code-cell} ipython3
250
- url = 'https://media.githubusercontent. com/media/ QuantEcon/high_dim_data/main/SCF_plus/SCF_plus_mini.csv'
250
+ url = 'https://github. com/QuantEcon/high_dim_data/raw /main/SCF_plus/SCF_plus_mini.csv'
251
251
df = pd.read_csv(url)
252
252
df_income_wealth = df.dropna()
253
253
```
@@ -619,46 +619,11 @@ We will use US data from the {ref}`Survey of Consumer Finances<data:survey-consu
619
619
df_income_wealth.year.describe()
620
620
```
621
621
622
- This code can be used to compute this information over the full dataset.
622
+ {download} ` This notebook <_static/lecture_specific/inequality/data.ipynb> ` can be used to compute this information over the full dataset.
623
623
624
624
``` {code-cell} ipython3
625
- :tags: [skip-execution, hide-input, hide-output]
626
-
627
- !pip install quantecon
628
- import quantecon as qe
629
-
630
- varlist = ['n_wealth', # net wealth
631
- 't_income', # total income
632
- 'l_income'] # labor income
633
-
634
- df = df_income_wealth
635
-
636
- # create lists to store Gini for each inequality measure
637
- results = {}
638
-
639
- for var in varlist:
640
- # create lists to store Gini
641
- gini_yr = []
642
- for year in years:
643
- # repeat the observations according to their weights
644
- counts = list(round(df[df['year'] == year]['weights'] ))
645
- y = df[df['year'] == year][var].repeat(counts)
646
- y = np.asarray(y)
647
-
648
- rd.shuffle(y) # shuffle the sequence
649
-
650
- # calculate and store Gini
651
- gini = qe.gini_coefficient(y)
652
- gini_yr.append(gini)
653
-
654
- results[var] = gini_yr
655
-
656
- # Convert to DataFrame
657
- results = pd.DataFrame(results, index=years)
658
- ```
659
-
660
- ``` {code-cell} ipython3
661
- ginis = results
625
+ data_url = 'https://github.com/QuantEcon/lecture-python-intro/raw/main/lectures/_static/lecture_specific/inequality/usa-gini-nwealth-tincome-lincome.csv'
626
+ ginis = pd.read_csv(data_url, index_col='year')
662
627
ginis.head(n=5)
663
628
```
664
629
@@ -685,10 +650,6 @@ One possibility is that this change is mainly driven by technology.
685
650
686
651
However, we will see below that not all advanced economies experienced similar growth of inequality.
687
652
688
-
689
-
690
-
691
-
692
653
### Cross-country comparisons of income inequality
693
654
694
655
Earlier in this lecture we used ` wbgapi ` to get Gini data across many countries
0 commit comments