Code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px # How do laws shape womenâs jobs and entrepreneurship?
- How do they (laws) stop women from entering workforce?
- Barriers of entry?
- Council relationship has not proven? Do stronger laws close the gap? Earnings?
- WBL score correlates well to each sector? Which sector has seen the most growth
- Benchmark
- Fragile and Conflict States
(Elif Nisa Polat)# Load data
df_panel = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='WBL Panel 2024')
df_mobility = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='Mobility')
df_workplace = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='Workplace')
df_pay = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='Pay')
df_marriage = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='Marriage')
df_parenthood = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='Parenthood')
df_assets = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='Assets')
df_pension = pd.read_excel('Data/WBL2024-1-0-Historical-Panel-Data.xlsx',sheet_name='Pension')
df_laws_legal_2024 = pd.read_excel('Data/WBL2024-2-0.xlsx',sheet_name='Legal2.0')
df_sfw_legal_2024 = pd.read_excel('Data/WBL2024-2-0.xlsx',sheet_name='SF2.0')
df_sfw_economy2024 = pd.read_excel('Data/WBL2024-2-0.xlsx',sheet_name='EO_ByEconomy')
df_panel = df_panel[df_panel["Region"]== "Sub-Saharan Africa"]
df_mobility = df_mobility[df_mobility["Region"]== "Sub-Saharan Africa"]
df_workplace = df_workplace[df_workplace["Region"]== "Sub-Saharan Africa"]
df_pay = df_pay[df_pay["Region"]== "Sub-Saharan Africa"]
df_marriage = df_marriage[df_marriage["Region"]== "Sub-Saharan Africa"]
df_parenthood = df_parenthood[df_parenthood["Region"]== "Sub-Saharan Africa"]
df_assets = df_assets[df_assets["Region"]== "Sub-Saharan Africa"]
df_pension = df_pension[df_pension["Region"]== "Sub-Saharan Africa"]Index(['Economy', 'EconomyCode', 'Region', 'IncomeGroup', 'OVERALL', 'SAFETY',
'Does the law address child marriage?', 'Legal Basis',
'Does the law address sexual harassment?', 'Legal Basis.1',
'Does the law address domestic violence?', 'Legal Basis.2',
'Does the law address femicide?', 'Legal Basis.3', 'MOBILITY',
'Can a woman choose where to live in the same way as a man?',
'Legal Basis.4',
'Can a woman travel internationally in the same way as a man?',
'Legal Basis.5',
'Can a woman travel outside her home in the same way as a man?',
'Legal Basis.6',
'Do a woman and a man have equal rights to confer citizenship on their spouses and their children?',
'Legal Basis.7', 'WORKPLACE',
'Can a woman get a job in the same way as a man?', 'Legal Basis.8',
'Does the law explicitly prohibit discrimination in recruitment based on marital status, parental status, and age?',
'Legal Basis.9',
'Does the law prohibit discrimination in employment based on gender? ',
'Legal Basis.10',
'Does the law allow employees to request flexible work?',
'Legal Basis.11', 'PAY',
'Does the law mandate equal remuneration for work of equal value?',
'Legal Basis.12', 'Can a woman work at night in the same way as a man?',
'Legal Basis.13',
'Can a woman work in a job deemed dangerous in the same way as a man?',
'Legal Basis.14',
'Can a woman work in an industrial job in the same way as a man?',
'Legal Basis.15', 'MARRIAGE',
'Is the law free of legal provisions that require a married woman to obey her husband?',
'Legal Basis.16',
'Can a woman be âhead of householdâ or âhead of familyâ in the same way as a man? ',
'Legal Basis.17',
'Can a woman obtain a judgment of divorce in the same way as a man?',
'Legal Basis.18',
'Does a woman have the same rights to remarry as a man?',
'Legal Basis.19', 'PARENTHOOD',
'Is paid leave of at least 14 weeks available to mothers?',
'Legal Basis.20',
'Are leave benefits for mothers paid solely by the government? ',
'Legal Basis.21', 'Is paid leave available to fathers?',
'Legal Basis.22', 'Is dismissal of pregnant workers prohibited?',
'Legal Basis.23', 'CHILDCARE',
'Does the law establish the provision of center-based childcare services? ',
'Legal Basis.24',
'Does the law establish any form of support for families for childcare services?',
'Legal Basis.25',
'Does the law establish any form of support for nonstate childcare providers?',
'Legal Basis.26',
'Does the law establish quality standards for the provision of center-based childcare services?',
'Legal Basis.27', 'ENTREPRENEURSHIP',
'Can a woman undertake entrepreneurial activities in the same way as a man?',
'Legal Basis.28',
'Does the law prohibit discrimination in access to credit based on gender?',
'Legal Basis.29',
'Does the law prescribe a gender quota for corporate boards?',
'Legal Basis.30',
'Does the law include gender-sensitive procurement provisions for public procurement processes?',
'Legal Basis.31', 'ASSETS',
'Do a woman and a man have equal administrative power and ownership rights to immovable property, including land?',
'Legal Basis.32',
'Do sons and daughters have equal rights to inherit assets?',
'Legal Basis.33',
'Do male and female surviving spouses have equal rights to inherit assets? ',
'Legal Basis.34',
'Does the law provide for the valuation of nonmonetary contributions? ',
'Legal Basis.35', 'PENSION',
'Are the ages at which a woman and a man can retire with full pension benefits the same?',
'Legal Basis.36',
'Are the ages at which a woman and a man can retire with partial pension benefits the same?',
'Legal Basis.37',
'Is the mandatory retirement age for a woman and a man the same?',
'Legal Basis.38',
'Are periods of absence due to childcare accounted for in pension benefits?',
'Legal Basis.39'],
dtype='object')
(48, 95)
Index(['Economy', 'EconomyCode', 'Region', 'IncomeGroup', 'OVERALL', 'SAFETY',
'Does the law address child marriage?', 'Legal Basis',
'Does the law address sexual harassment?', 'Legal Basis.1',
'Does the law address domestic violence?', 'Legal Basis.2',
'Does the law address femicide?', 'Legal Basis.3', 'MOBILITY',
'Can a woman choose where to live in the same way as a man?',
'Legal Basis.4',
'Can a woman travel internationally in the same way as a man?',
'Legal Basis.5',
'Can a woman travel outside her home in the same way as a man?',
'Legal Basis.6',
'Do a woman and a man have equal rights to confer citizenship on their spouses and their children?',
'Legal Basis.7', 'WORKPLACE',
'Can a woman get a job in the same way as a man?', 'Legal Basis.8',
'Does the law explicitly prohibit discrimination in recruitment based on marital status, parental status, and age?',
'Legal Basis.9',
'Does the law prohibit discrimination in employment based on gender? ',
'Legal Basis.10',
'Does the law allow employees to request flexible work?',
'Legal Basis.11', 'PAY',
'Does the law mandate equal remuneration for work of equal value?',
'Legal Basis.12', 'Can a woman work at night in the same way as a man?',
'Legal Basis.13',
'Can a woman work in a job deemed dangerous in the same way as a man?',
'Legal Basis.14',
'Can a woman work in an industrial job in the same way as a man?',
'Legal Basis.15', 'MARRIAGE',
'Is the law free of legal provisions that require a married woman to obey her husband?',
'Legal Basis.16',
'Can a woman be âhead of householdâ or âhead of familyâ in the same way as a man? ',
'Legal Basis.17',
'Can a woman obtain a judgment of divorce in the same way as a man?',
'Legal Basis.18',
'Does a woman have the same rights to remarry as a man?',
'Legal Basis.19', 'PARENTHOOD',
'Is paid leave of at least 14 weeks available to mothers?',
'Legal Basis.20',
'Are leave benefits for mothers paid solely by the government? ',
'Legal Basis.21', 'Is paid leave available to fathers?',
'Legal Basis.22', 'Is dismissal of pregnant workers prohibited?',
'Legal Basis.23', 'CHILDCARE',
'Does the law establish the provision of center-based childcare services? ',
'Legal Basis.24',
'Does the law establish any form of support for families for childcare services?',
'Legal Basis.25',
'Does the law establish any form of support for nonstate childcare providers?',
'Legal Basis.26',
'Does the law establish quality standards for the provision of center-based childcare services?',
'Legal Basis.27', 'ENTREPRENEURSHIP',
'Can a woman undertake entrepreneurial activities in the same way as a man?',
'Legal Basis.28',
'Does the law prohibit discrimination in access to credit based on gender?',
'Legal Basis.29',
'Does the law prescribe a gender quota for corporate boards?',
'Legal Basis.30',
'Does the law include gender-sensitive procurement provisions for public procurement processes?',
'Legal Basis.31', 'ASSETS',
'Do a woman and a man have equal administrative power and ownership rights to immovable property, including land?',
'Legal Basis.32',
'Do sons and daughters have equal rights to inherit assets?',
'Legal Basis.33',
'Do male and female surviving spouses have equal rights to inherit assets? ',
'Legal Basis.34',
'Does the law provide for the valuation of nonmonetary contributions? ',
'Legal Basis.35', 'PENSION',
'Are the ages at which a woman and a man can retire with full pension benefits the same?',
'Legal Basis.36',
'Are the ages at which a woman and a man can retire with partial pension benefits the same?',
'Legal Basis.37',
'Is the mandatory retirement age for a woman and a man the same?',
'Legal Basis.38',
'Are periods of absence due to childcare accounted for in pension benefits?',
'Legal Basis.39'],
dtype='object')
Economy EconomyCode Region IncomeGroup \
3 Angola AGO Sub-Saharan Africa Lower middle income
17 Benin BEN Sub-Saharan Africa Lower middle income
21 Botswana BWA Sub-Saharan Africa Upper middle income
25 Burkina Faso BFA Sub-Saharan Africa Low income
26 Burundi BDI Sub-Saharan Africa Low income
OVERALL SAFETY Does the law address child marriage? \
3 62.5 25 No
17 70.0 50 No
21 52.5 25 No
25 65.0 50 No
26 52.5 50 Yes
Legal Basis \
3 No applicable provisions could be located
17 No applicable provisions could be located
21 No applicable provisions could be located
25 No applicable provisions could be located
26 Loi No. 1/024 du 28 Avril 1993 Portant Réforme...
Does the law address sexual harassment? \
3 No
17 Yes
21 No
25 Yes
26 No
Legal Basis.1 ... \
3 No applicable provisions could be located ...
17 Loi No. 2011-26 du 09 janvier 2012 portant pré... ...
21 No applicable provisions could be located ...
25 Code du Travail, Arts. 37 et 422; Loi No. 061-... ...
26 No applicable provisions could be located ...
Legal Basis.35 PENSION \
3 Family Code, Arts. 49, 110 and 111 25
17 Loi no. 2002-07 portant code des personnes et ... 100
21 Married Persons Property Act, Art. 4(1) 100
25 Code des personnes et de la famille, Arts. 309... 100
26 Code des personnes et de la famille, Art. 126 75
Are the ages at which a woman and a man can retire with full pension benefits the same? \
3 No
17 Yes
21 Yes
25 Yes
26 Yes
Legal Basis.36 \
3 Presidential Decree 299/20, Art. 4
17 Loi No. 2010-10 du 22 mars 2010, Art. 1er
21 Universal Pension and Orphan Care Act 1996
25 Loi no. 004-2021/AN du 6 avril 2021, Art. 94; ...
26 Code de la Sécurité Sociale, Arts. 67 et 68
Are the ages at which a woman and a man can retire with partial pension benefits the same? \
3 Yes
17 Yes
21 Yes
25 Yes
26 Yes
Legal Basis.37 \
3 No applicable provisions could be located
17 Loi No. 2010-10 du 22 mars 2010, Art. 1er
21 No applicable provisions could be located
25 No applicable provisions could be located
26 No applicable provisions could be located
Is the mandatory retirement age for a woman and a man the same? \
3 No
17 Yes
21 Yes
25 Yes
26 Yes
Legal Basis.38 \
3 General Labor Law, Art. 199(1)(c); Presidentia...
17 No applicable provisions could be located
21 No applicable provisions could be located
25 No applicable provisions could be located
26 Code du Travail, Art. 164
Are periods of absence due to childcare accounted for in pension benefits? \
3 No
17 Yes
21 Yes
25 Yes
26 No
Legal Basis.39
3 No applicable provisions could be located
17 Code de Sécurité Sociale, Art. 101
21 Universal Pension and Orphan Care Act 1996
25 Loi No. 004â2021/AN du 6 avril 2021, Arts. 92 ...
26 No applicable provisions could be located
[5 rows x 95 columns]
<class 'pandas.core.frame.DataFrame'>
Index: 48 entries, 3 to 189
Data columns (total 95 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Economy 48 non-null object
1 EconomyCode 48 non-null object
2 Region 48 non-null object
3 IncomeGroup 48 non-null object
4 OVERALL 48 non-null float64
5 SAFETY 48 non-null int64
6 Does the law address child marriage? 48 non-null object
7 Legal Basis 48 non-null object
8 Does the law address sexual harassment? 48 non-null object
9 Legal Basis.1 48 non-null object
10 Does the law address domestic violence? 48 non-null object
11 Legal Basis.2 48 non-null object
12 Does the law address femicide? 48 non-null object
13 Legal Basis.3 48 non-null object
14 MOBILITY 48 non-null int64
15 Can a woman choose where to live in the same way as a man? 48 non-null object
16 Legal Basis.4 48 non-null object
17 Can a woman travel internationally in the same way as a man? 48 non-null object
18 Legal Basis.5 48 non-null object
19 Can a woman travel outside her home in the same way as a man? 48 non-null object
20 Legal Basis.6 48 non-null object
21 Do a woman and a man have equal rights to confer citizenship on their spouses and their children? 48 non-null object
22 Legal Basis.7 48 non-null object
23 WORKPLACE 48 non-null int64
24 Can a woman get a job in the same way as a man? 48 non-null object
25 Legal Basis.8 48 non-null object
26 Does the law explicitly prohibit discrimination in recruitment based on marital status, parental status, and age? 48 non-null object
27 Legal Basis.9 48 non-null object
28 Does the law prohibit discrimination in employment based on gender? 48 non-null object
29 Legal Basis.10 48 non-null object
30 Does the law allow employees to request flexible work? 48 non-null object
31 Legal Basis.11 48 non-null object
32 PAY 48 non-null int64
33 Does the law mandate equal remuneration for work of equal value? 48 non-null object
34 Legal Basis.12 48 non-null object
35 Can a woman work at night in the same way as a man? 48 non-null object
36 Legal Basis.13 48 non-null object
37 Can a woman work in a job deemed dangerous in the same way as a man? 48 non-null object
38 Legal Basis.14 48 non-null object
39 Can a woman work in an industrial job in the same way as a man? 48 non-null object
40 Legal Basis.15 48 non-null object
41 MARRIAGE 48 non-null int64
42 Is the law free of legal provisions that require a married woman to obey her husband? 48 non-null object
43 Legal Basis.16 48 non-null object
44 Can a woman be âhead of householdâ or âhead of familyâ in the same way as a man? 48 non-null object
45 Legal Basis.17 48 non-null object
46 Can a woman obtain a judgment of divorce in the same way as a man? 48 non-null object
47 Legal Basis.18 48 non-null object
48 Does a woman have the same rights to remarry as a man? 48 non-null object
49 Legal Basis.19 48 non-null object
50 PARENTHOOD 48 non-null int64
51 Is paid leave of at least 14 weeks available to mothers? 48 non-null object
52 Legal Basis.20 48 non-null object
53 Are leave benefits for mothers paid solely by the government? 48 non-null object
54 Legal Basis.21 48 non-null object
55 Is paid leave available to fathers? 48 non-null object
56 Legal Basis.22 48 non-null object
57 Is dismissal of pregnant workers prohibited? 48 non-null object
58 Legal Basis.23 48 non-null object
59 CHILDCARE 48 non-null int64
60 Does the law establish the provision of center-based childcare services? 48 non-null object
61 Legal Basis.24 48 non-null object
62 Does the law establish any form of support for families for childcare services? 48 non-null object
63 Legal Basis.25 48 non-null object
64 Does the law establish any form of support for nonstate childcare providers? 48 non-null object
65 Legal Basis.26 48 non-null object
66 Does the law establish quality standards for the provision of center-based childcare services? 48 non-null object
67 Legal Basis.27 48 non-null object
68 ENTREPRENEURSHIP 48 non-null int64
69 Can a woman undertake entrepreneurial activities in the same way as a man? 48 non-null object
70 Legal Basis.28 48 non-null object
71 Does the law prohibit discrimination in access to credit based on gender? 48 non-null object
72 Legal Basis.29 48 non-null object
73 Does the law prescribe a gender quota for corporate boards? 48 non-null object
74 Legal Basis.30 48 non-null object
75 Does the law include gender-sensitive procurement provisions for public procurement processes? 48 non-null object
76 Legal Basis.31 48 non-null object
77 ASSETS 48 non-null int64
78 Do a woman and a man have equal administrative power and ownership rights to immovable property, including land? 48 non-null object
79 Legal Basis.32 48 non-null object
80 Do sons and daughters have equal rights to inherit assets? 48 non-null object
81 Legal Basis.33 48 non-null object
82 Do male and female surviving spouses have equal rights to inherit assets? 48 non-null object
83 Legal Basis.34 48 non-null object
84 Does the law provide for the valuation of nonmonetary contributions? 48 non-null object
85 Legal Basis.35 48 non-null object
86 PENSION 48 non-null int64
87 Are the ages at which a woman and a man can retire with full pension benefits the same? 48 non-null object
88 Legal Basis.36 48 non-null object
89 Are the ages at which a woman and a man can retire with partial pension benefits the same? 48 non-null object
90 Legal Basis.37 48 non-null object
91 Is the mandatory retirement age for a woman and a man the same? 48 non-null object
92 Legal Basis.38 48 non-null object
93 Are periods of absence due to childcare accounted for in pension benefits? 48 non-null object
94 Legal Basis.39 48 non-null object
dtypes: float64(1), int64(10), object(84)
memory usage: 36.0+ KB
None
OVERALL SAFETY MOBILITY WORKPLACE PAY MARRIAGE \
count 48.000000 48.000000 48.000000 48.000000 48.000000 48.000000
mean 57.395833 29.687500 81.250000 49.479167 69.270833 71.354167
std 13.980974 21.047218 22.773164 18.941106 28.359200 30.066232
min 20.000000 0.000000 0.000000 0.000000 0.000000 0.000000
25% 50.000000 25.000000 75.000000 50.000000 50.000000 50.000000
50% 56.250000 25.000000 75.000000 50.000000 75.000000 75.000000
75% 68.125000 50.000000 100.000000 50.000000 100.000000 100.000000
max 87.500000 75.000000 100.000000 100.000000 100.000000 100.000000
PARENTHOOD CHILDCARE ENTREPRENEURSHIP ASSETS PENSION
count 48.000000 48.000000 48.000000 48.000000 48.000000
mean 60.416667 19.270833 41.145833 71.354167 80.729167
std 28.168062 22.620589 22.175307 29.620644 23.201008
min 0.000000 0.000000 0.000000 0.000000 25.000000
25% 50.000000 0.000000 25.000000 50.000000 75.000000
50% 62.500000 25.000000 50.000000 75.000000 75.000000
75% 75.000000 25.000000 50.000000 100.000000 100.000000
max 100.000000 100.000000 75.000000 100.000000 100.000000
# Correlation Matrix for Women, Business and the Law 2.0 Data for 20244
numeric_cols = df_laws_legal_2024.select_dtypes(include=[np.number]).columns
correlation = df_laws_legal_2024[numeric_cols].corr()
plt.figure(figsize=(12,10))
sns.heatmap(correlation, annot=True, fmt='.2f', cmap='coolwarm',
center=0, square=True, linewidths=1)
plt.title('Correlation Matrix')
plt.tight_layout()
plt.show()
# Notes: 
# ===== PHASE 1: DATA UNDERSTANDING =====
# Basic info
print(df.shape) # (rows, columns)
print(df.columns)
print(df.head())
print(df.info())
print(df.describe())
# Missing values
print(df.isnull().sum())
missing_pct = (df.isnull().sum() / len(df)) * 100
print(missing_pct[missing_pct > 0])
# ===== PHASE 2: UNIVARIATE ANALYSIS =====
# Distribution of female LFPR
plt.figure(figsize=(10,6))
df['female_lfpr'].hist(bins=30, edgecolor='black')
plt.xlabel('Female Labor Force Participation Rate (%)')
plt.ylabel('Number of Countries')
plt.title('Distribution of Female LFPR Across Countries')
plt.show()
# Box plot to check outliers
df.boxplot(column=['female_lfpr', 'male_lfpr'])
plt.title('Employment Rates by Gender')
plt.show()
# ===== PHASE 3: BIVARIATE ANALYSIS =====
# Correlation heatmap
numeric_cols = df.select_dtypes(include=[np.number]).columns
correlation = df[numeric_cols].corr()
plt.figure(figsize=(12,10))
sns.heatmap(correlation, annot=True, fmt='.2f', cmap='coolwarm',
center=0, square=True, linewidths=1)
plt.title('Correlation Matrix')
plt.tight_layout()
plt.show()
# Scatter plot: Legal rights vs Female LFPR
plt.figure(figsize=(10,6))
sns.regplot(x='wbl_score', y='female_lfpr', data=df,
scatter_kws={'alpha':0.6}, line_kws={'color':'red'})
plt.xlabel('Women Business and Law Score')
plt.ylabel('Female LFPR (%)')
plt.title('Legal Rights vs Women\'s Employment')
plt.show()
# Box plot by region
plt.figure(figsize=(12,6))
df.boxplot(column='female_lfpr', by='region', figsize=(12,6))
plt.xlabel('Region')
plt.ylabel('Female LFPR (%)')
plt.title('Female Employment Rates by Region')
plt.suptitle('') # Remove default title
plt.show()
# ===== PHASE 4: MULTIVARIATE ANALYSIS =====
# Interactive scatter with plotly
fig = px.scatter(df, x='wbl_score', y='female_lfpr',
size='population', color='region',
hover_name='country',
title='Legal Rights vs Employment (bubble size = population)')
fig.show()
# Faceted scatter plots by region
g = sns.FacetGrid(df, col='region', col_wrap=3, height=4)
g.map(sns.scatterplot, 'wbl_score', 'female_lfpr')
g.add_legend()
plt.show()
# ===== PHASE 5: TIME SERIES =====
# If you have time series data
time_series_df = df[df['country'].isin(['Rwanda', 'India', 'Brazil'])]
plt.figure(figsize=(12,6))
for country in ['Rwanda', 'India', 'Brazil']:
country_data = time_series_df[time_series_df['country'] == country]
plt.plot(country_data['year'], country_data['female_lfpr'],
marker='o', label=country)
plt.xlabel('Year')
plt.ylabel('Female LFPR (%)')
plt.title('Female Employment Trends: Selected Countries')
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()
# ===== PHASE 6: GAP ANALYSIS =====
# Calculate gender gap
df['gender_gap'] = df['male_lfpr'] - df['female_lfpr']
# Top 10 largest gaps
top_gaps = df.nlargest(10, 'gender_gap')[['country', 'gender_gap']]
print(top_gaps)
# Visualize
plt.figure(figsize=(10,6))
top_gaps.plot(x='country', y='gender_gap', kind='barh', legend=False)
plt.xlabel('Gender Employment Gap (percentage points)')
plt.title('Countries with Largest Gender Gaps in Employment')
plt.tight_layout()
plt.show()
# ===== EXPORT FOR TABLEAU =====
# Clean data and save for Tableau
df_clean = df.dropna(subset=['female_lfpr', 'wbl_score'])
df_clean.to_csv('cleaned_data_for_tableau.csv', index=False)