Python
All Top Python Interview Questions#30
Normalize Inconsistent Boolean Flags in Pandas
EasyInterview Question #30
Given a column with dirty boolean values like `['yes', 'Y', '1', 'no', 'N', '0', None]`, normalize them into pure `True`, `False`, and `pd.NA` boolean dtypes.
Input Table: df
3 rows preview| subscribed |
|---|
| YES |
| 0 |
| N |
Expected Output Structure3 rows
| clean_subscribed |
|---|
| true |
| false |
| false |
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)…