chore(script): Move inequality and region breakdowns to discussion

This commit is contained in:
Marty Oehme 2023-12-22 19:27:20 +01:00
parent 1efa2a938c
commit e3315d402f
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -604,63 +604,6 @@ by_intervention = None
{{++ TODO: describe intervention types with complete dataset ++}} {{++ TODO: describe intervention types with complete dataset ++}}
```{python}
#| label: fig-inequality-types
#| fig-cap: Types of inequality analyzed
by_inequality = (
bib_df.groupby(["author", "year", "title"])
.agg(
{
"inequality": lambda _col: "; ".join(_col),
}
)
.reset_index()
.drop_duplicates()
.assign(
inequality=lambda _df: _df["inequality"].apply(
lambda _cell: set([x.strip() for x in _cell.split(";")])
),
)
.explode("inequality")
)
sort_order = by_inequality["inequality"].value_counts().index
fig = plt.figure()
fig.set_size_inches(6, 3)
ax = sns.countplot(by_inequality, x="inequality", order=by_inequality["inequality"].value_counts().index)
plt.setp(ax.get_xticklabels(), rotation=45, ha="right",
rotation_mode="anchor")
plt.show()
by_inequality = None
```
Income inequality is the primary type of inequality interrogated in most of the relevant studies.
This follows the identified lens income inequality can provide through which to understand other inequalities ---
many studies use income measurements and changes in income or income inequality over time as indicators to understand a variety of other inequalities' linkages through.
{{++ TODO: describe inequality type distribution for overall dataset ++}}
```{python}
#| label: fig-region-counts
#| fig-cap: Studies by regions analysed
bib_df = (bib_df
.assign(
# create de-duplicated joins for all observations
region=lambda _df: _df["region"].apply(
lambda _cell: set([x.strip() for x in _cell.split(";")])
),
)
.explode("region")
)
# bib_df["region"] = bib_df["region"].str.split(";").explode().str.strip()
ax = sns.countplot(bib_df, x="region", order=bib_df["region"].value_counts().index)
plt.setp(ax.get_xticklabels(), rotation=45, ha="right",
rotation_mode="anchor")
plt.show()
```
# Synthesis of Evidence --- a multitude of lenses # Synthesis of Evidence --- a multitude of lenses
This section will present a synthesis of evidence from the scoping review. This section will present a synthesis of evidence from the scoping review.
@ -1048,19 +991,62 @@ The authors suggest the primary channel is the newly increased bargaining power
[^1]: The Mahatma Gandhi National Rural Employment Guarantee Scheme, one of the largest redistribution programmes on the household level in the world, entitling each household to up to 100 days of work per year. [^1]: The Mahatma Gandhi National Rural Employment Guarantee Scheme, one of the largest redistribution programmes on the household level in the world, entitling each household to up to 100 days of work per year.
# Results for horizontal inequalities # Discussion
```{python} ```{python}
# dataframe containing each intervention inequality pair # dataframe containing each intervention inequality pair
df_inequality = bib_df[["intervention", "inequality"]].copy().reset_index(drop=True) df_inequality = (
df_inequality['Inequality'] = df_inequality['inequality'].str.split(";").explode(ignore_index=True).str.strip() bib_df[["region", "intervention", "inequality"]]
df_inequality['Intervention'] = df_inequality['intervention'].str.split(";").explode(ignore_index=True).str.replace(r"\(.+\)", "", regex=True).str.strip() .assign(
Intervention = lambda _df: (_df["intervention"]
.str.replace(r"\(.+\)", "", regex=True)
.str.replace(r" ?; ?", ";", regex=True)
.str.strip()
.str.split(";")
),
inequality = lambda _df: (_df["inequality"]
.str.replace(r"\(.+\)", "", regex=True)
.str.replace(r" ?; ?", ";", regex=True)
.str.strip()
.str.split(";")
)
)
.explode("Intervention")
.explode("inequality")
.reset_index(drop=True)
)
def crosstab_inequality(df, inequality:str): def crosstab_inequality(df, inequality:str, **kwargs):
df_temp = df.loc[(df["Inequality"] == inequality) | (df["Inequality"] == "income")] df_temp = df.loc[(df["inequality"] == inequality) | (df["inequality"] == "income")]
tab = pd.crosstab(df_temp["Intervention"], df_temp["Inequality"]) tab = pd.crosstab(df_temp["Intervention"], df_temp["inequality"], **kwargs)
return tab.drop(tab[tab[inequality] == 0].index) return tab.drop(tab[tab[inequality] == 0].index)
```
```{python}
#| label: fig-region-counts
#| fig-cap: Studies by regions analysed
by_region = (
bib_df[["region"]]
.assign(
region = lambda _df: (_df["region"]
.str.replace(r" ?; ?", ";", regex=True)
.str.strip()
.str.split(";")
)
)
.explode("region")
.reset_index(drop=True)
)
ax = sns.countplot(by_region, x="region", order=by_region["region"].value_counts().index)
plt.setp(ax.get_xticklabels(), rotation=45, ha="right",
rotation_mode="anchor")
plt.show()
def regions_for_inequality(df, inequality:str):
df_temp = df.loc[(df["inequality"] == inequality)]
return sns.countplot(df_temp, x="region", order=df_temp["region"].value_counts().index)
``` ```
## Gender inequality ## Gender inequality