Pandas data cleaning
Write a function clean_dataframe(df) that handles: (1) drops exact duplicate rows, (2) fills numeric nulls with column median, (3) fills string nulls with "unknown", (4) strips leading/trailing whitespace from all string columns. Return the cleaned DataFrame.
How is an answer to this question scored?
PrepGraph scores a written answer against 5 criteria specific to this question, then returns a rubric score and written feedback. The criteria cover what a strong answer has to establish, the trade-offs it has to name, and the traps it has to avoid. Pandas data cleaning is a intermediate question in Coding, one of 88 Data Science questions in the Arena.
The criteria themselves and the AI feedback are available after you sign in. The question above is shown in full.
What should I know before answering?
This question connects to 2 related ideas. Working through them first usually makes the answer easier to structure, because interviewers expect a candidate to move between them without being prompted.
- Feature engineering
- ETL pipelines