How do you detect, drop, and fill missing values in pandas?

Quick Overview

Asks how to find, drop and fill missing values in a pandas DataFrame, and when each approach fits. It tests working knowledge of the pandas missing-data API and judgment about information loss and leakage during imputation.

How do you detect, drop, and fill missing values in pandas?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

How do you detect, drop, and fill missing values in pandas? Assume a DataFrame `df` that mixes numeric and text columns. ```hint Check what each call returns Look at which values pandas counts as missing, and whether each method returns a mask, a new frame, or changes `df` in place. ``` ### What a Strong Answer Covers - The calls that find missing values and summarize them per column and per row. - How to drop rows or columns, and the options that control which ones go. - The fill options: constants, statistics, directional fills, interpolation, and per-column or per-group values. - How to choose between dropping and filling, including the information lost and the leakage risk when fill values come from all the data. ### Follow-up Questions - A column marks missing values with -999 and empty strings. How do you make pandas treat them as missing? - How would you impute a numeric feature for a train/test split without leaking test information? - Why does an integer column turn into floats once a NaN appears, and what do nullable dtypes change?

Overview: Asks how to find, drop and fill missing values in a pandas DataFrame, and when each approach fits. It tests working knowledge of the pandas missing-data API and judgment about information loss and leakage during imputation.

PracHub logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

How do you detect, drop, and fill missing values in pandas?

Assume a DataFrame df that mixes numeric and text columns.

What a Strong Answer Covers Guidance

  • The calls that find missing values and summarize them per column and per row.
  • How to drop rows or columns, and the options that control which ones go.
  • The fill options: constants, statistics, directional fills, interpolation, and per-column or per-group values.
  • How to choose between dropping and filling, including the information lost and the leakage risk when fill values come from all the data.

Follow-up Questions Guidance

  • A column marks missing values with -999 and empty strings. How do you make pandas treat them as missing?
  • How would you impute a numeric feature for a train/test split without leaking test information?
  • Why does an integer column turn into floats once a NaN appears, and what do nullable dtypes change?