Beispiel 2
Beispiel 2¶
Ein anderes Beispiel mit Gender Pay Gap Dataset von hier: https://www.kaggle.com/nilimajauhari/glassdoor-analyze-gender-pay-gap
import pandas as pd
import plotly.express as px
# Hier muss man natürlich noch anpassen an sein Working Directory:
da = pd.read_csv('data/Glassdoor_Gender_Pay_Gap.csv')
da.head()
JobTitle | Gender | Age | PerfEval | Education | Dept | Seniority | BasePay | Bonus | |
---|---|---|---|---|---|---|---|---|---|
0 | Graphic Designer | Female | 18 | 5 | College | Operations | 2 | 42363 | 9938 |
1 | Software Engineer | Male | 21 | 5 | College | Management | 5 | 108476 | 11128 |
2 | Warehouse Associate | Female | 19 | 4 | PhD | Administration | 5 | 90208 | 9268 |
3 | Software Engineer | Male | 20 | 5 | Masters | Sales | 4 | 108080 | 10154 |
4 | Graphic Designer | Male | 26 | 5 | Masters | Engineering | 5 | 99464 | 9319 |
# Und jetzt ein Scatter Plot mit ein paar ganz wenigen Tweaks:
fig = px.scatter(da, x ='Age', y='BasePay', color='Gender', hover_name='JobTitle',
title='Annual basepay by age and gender')
fig.show()
# Und ein Boxplot für die verschiedenen "Departments"
fig = px.box(da, x='Dept', y='BasePay', color='Gender',
title='Gender differences in pay distribution per department')
fig.show()