Python
All Top Python Interview Questions#35
Contingency Tables with pd.crosstab() in Pandas
EasyInterview Question #35
Given customer survey records with `device_type` and `churn_status`, compute a normalized percentage cross-tabulation table showing churn rates by device.
Input Table: df
3 rows preview| device_type | churn_status |
|---|---|
| iOS | Retained |
| iOS | Churned |
| Android | Retained |
Expected Output Structure2 rows
| device_type | Churned | Retained |
|---|---|---|
| Android | 0 | 1 |
| iOS | 0.5 | 0.5 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
Python 3.10 (Pandas)
Environment Ready
Starting the real Python + pandas runtime (one-time download)…