Analyzing Survey Data in Python
EbunOluwa Andrew
Data Scientist
.crosstab()
-> examines the inter-relationship between two nominal variables.print(survey.head())
| Age | Occupation_Title | Current Student | Gender | Education |
|---------|---------------------------|-----------------|--------|------------|
| 18 - 24 | Credit officer | No | Female | Bachelor's |
| 18 - 24 | Student | Yes, Full-Time | Male | Bachelor's |
| 18 - 24 | Student | Yes, Full-Time | Female | Bachelor's |
| 25 - 34 | Senior Financial Analyst | No | Female | Bachelor's |
| 35 - 44 | Public Relations Director | No | Female | Bachelor's |
cross_tabulation = pd.crosstab(survey.Age, survey.Gender)
cross_tabulation
| | Female | Male |
|---------|--------|------|
| 18 - 24 | 39 | 12 |
| 25 - 34 | 28 | 12 |
| 35 - 44 | 5 | 1 |
| 45 - 54 | 3 | 0 |
Analyzing Survey Data in Python