Skip to content

Commit 255cad1

Browse files
Remove some white spaces
1 parent 23a9913 commit 255cad1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lectures/inequality.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ varlist = ['n_wealth', # net wealth
414414
't_income', # total income
415415
'l_income'] # labor income
416416
417-
df = df_income_wealth
417+
df = df_income_wealth
418418
419419
# create lists to store Gini for each inequality measure
420420
@@ -426,7 +426,7 @@ for var in varlist:
426426
427427
for year in years:
428428
# repeat the observations according to their weights
429-
counts = list(round(df[df['year'] == year]['weights'] ))
429+
counts = list(round(df[df['year'] == year]['weights'] ))
430430
y = df[df['year'] == year][var].repeat(counts)
431431
y = np.asarray(y)
432432
@@ -448,7 +448,7 @@ Let's plot the Gini coefficients for net wealth, labor income and total income.
448448
```{code-cell} ipython3
449449
# use an average to replace an outlier in labor income gini
450450
ginis_li_new = ginis_li
451-
ginis_li_new[5] = (ginis_li[4] + ginis_li[6]) / 2
451+
ginis_li_new[5] = (ginis_li[4] + ginis_li[6]) / 2
452452
```
453453

454454
```{code-cell} ipython3
@@ -493,7 +493,7 @@ ax.plot(years, ginis_ti, marker='o', label="total income")
493493
ax.set_xlabel(xlabel, fontsize=12)
494494
ax.set_ylabel(ylabel, fontsize=12)
495495
496-
ax.legend(fontsize=12)
496+
ax.legend(fontsize=12)
497497
plt.show()
498498
```
499499

@@ -540,16 +540,16 @@ The following code uses the data from dataframe ``df_income_wealth`` to generate
540540
# transfer the survey weights from absolute into relative values
541541
df1 = df_income_wealth
542542
df2 = df1.groupby('year').sum(numeric_only=True).reset_index()
543-
df3 = df2[['year', 'weights']]
544-
df3.columns = 'year', 'r_weights'
545-
df4 = pd.merge(df3, df1, how="left", on=["year"])
546-
df4['r_weights'] = df4['weights'] / df4['r_weights']
543+
df3 = df2[['year', 'weights']]
544+
df3.columns = 'year', 'r_weights'
545+
df4 = pd.merge(df3, df1, how="left", on=["year"])
546+
df4['r_weights'] = df4['weights'] / df4['r_weights']
547547
548548
# create weighted nw, ti, li
549549
550-
df4['weighted_n_wealth'] = df4['n_wealth'] * df4['r_weights']
551-
df4['weighted_t_income'] = df4['t_income'] * df4['r_weights']
552-
df4['weighted_l_income'] = df4['l_income'] * df4['r_weights']
550+
df4['weighted_n_wealth'] = df4['n_wealth'] * df4['r_weights']
551+
df4['weighted_t_income'] = df4['t_income'] * df4['r_weights']
552+
df4['weighted_l_income'] = df4['l_income'] * df4['r_weights']
553553
554554
# extract two top 10% groups by net wealth and total income.
555555
@@ -559,7 +559,7 @@ df7 = df4[df4['ti_groups'] == 'Top 10%']
559559
# calculate the sum of weighted top 10% by net wealth,
560560
# total income and labor income.
561561
562-
df5 = df4.groupby('year').sum(numeric_only=True).reset_index()
562+
df5 = df4.groupby('year').sum(numeric_only=True).reset_index()
563563
df8 = df6.groupby('year').sum(numeric_only=True).reset_index()
564564
df9 = df7.groupby('year').sum(numeric_only=True).reset_index()
565565
@@ -578,7 +578,7 @@ df5['topshare_l_income'] = df5['weighted_l_income_top10'] / \
578578
579579
# we only need these vars for top 10 percent shares
580580
df_topshares = df5[['year', 'topshare_n_wealth',
581-
'topshare_t_income', 'topshare_l_income']]
581+
'topshare_t_income', 'topshare_l_income']]
582582
```
583583
584584
Then let's plot the top shares.

0 commit comments

Comments
 (0)