You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lectures/inequality.md
+6-9Lines changed: 6 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,8 @@ The curve $L$ is just a function $y = L(x)$ that we can plot and interpret.
103
103
To create it we first generate data points $(x_i, y_i)$ according to
104
104
105
105
```{prf:definition}
106
+
:label: define-lorenz
107
+
106
108
$$
107
109
x_i = \frac{i}{n},
108
110
\qquad
@@ -137,7 +139,6 @@ income or wealth data into the cumulative share
137
139
of individuals (or households) and the cumulative share of income (or wealth).
138
140
139
141
```{code-cell} ipython3
140
-
:tags: [hide-input]
141
142
142
143
def lorenz_curve(y):
143
144
"""
@@ -350,7 +351,7 @@ $$
350
351
The Gini coefficient is closely related to the Lorenz curve.
351
352
352
353
In fact, it can be shown that its value is twice the area between the line of
353
-
equality and the Lorenz curve (e.g., the shaded area in the following Figure below).
354
+
equality and the Lorenz curve (e.g., the shaded area in {numref}`lorenz_gini`).
354
355
355
356
The idea is that $G=0$ indicates complete equality, while $G=1$ indicates complete inequality.
356
357
@@ -524,9 +525,7 @@ wb.search("gini")
524
525
525
526
We now know the series ID is `SI.POV.GINI`.
526
527
527
-
```{tip}
528
528
Another, and often useful way to find series ID, is to use the [World Bank data portal](https://data.worldbank.org) and then use `wbgapi` to fetch the data.
529
-
```
530
529
531
530
Let us fetch the data for the USA and request for it to be returned as a `DataFrame`.
532
531
@@ -536,9 +535,7 @@ data.head(n=5)
536
535
data.columns = data.columns.map(lambda x: int(x.replace('YR',''))) # remove 'YR' in index and convert to int
537
536
```
538
537
539
-
```{tip}
540
-
This package often returns data with year information contained in the columns. This is not always convenient for simple plotting with pandas so it can be useful to transpose the results before plotting
541
-
```
538
+
**Note:** This package often returns data with year information contained in the columns. This is not always convenient for simple plotting with pandas so it can be useful to transpose the results before plotting
542
539
543
540
```{code-cell} ipython3
544
541
data = data.T # transpose to get data series as columns and years as rows
0 commit comments