What are the axis, how, and thresh options of pandas dropna()?

Quick Overview

Asks what the axis, how and thresh arguments of the pandas dropna() method do and how they combine with subset. Tests practical handling of missing data in DataFrames and awareness of the pitfalls that silently remove too many rows.

What are the axis, how, and thresh options of pandas dropna()?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

What are the `axis`, `how`, and `thresh` options of `dropna()`? Assume a pandas DataFrame with missing values scattered across several rows and columns. ```hint Count first For each row, count the values that are present. Most of the behavior follows from comparing that count with the row's length or with a number you supply. ``` ### What a Strong Answer Covers - What `axis` controls and what its default is - The difference between `how='any'` and `how='all'`, and which one is the default - What `thresh` counts and how it interacts with `how` and `subset` - Which values pandas treats as missing - A small example showing the effect of each option ### Follow-up Questions - How would you drop every column that is more than 20% missing? - Why can `df.dropna()` return an empty DataFrame, and how would you catch that early? - What does `df = df.dropna(inplace=True)` leave in `df`? - When is dropping rows with missing values the wrong way to handle them?

Overview: Asks what the axis, how and thresh arguments of the pandas dropna() method do and how they combine with subset. Tests practical handling of missing data in DataFrames and awareness of the pitfalls that silently remove too many rows.

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

What are the axis, how, and thresh options of dropna()?

Assume a pandas DataFrame with missing values scattered across several rows and columns.

What a Strong Answer Covers Guidance

  • What axis controls and what its default is
  • The difference between how='any' and how='all' , and which one is the default
  • What thresh counts and how it interacts with how and subset
  • Which values pandas treats as missing
  • A small example showing the effect of each option

Follow-up Questions Guidance

  • How would you drop every column that is more than 20% missing?
  • Why can df.dropna() return an empty DataFrame, and how would you catch that early?
  • What does df = df.dropna(inplace=True) leave in df ?
  • When is dropping rows with missing values the wrong way to handle them?