Category: pandas

Problem

Fill or drop NaN values in datasets.

Solution

  df = df.fillna({"age": df["age"].median()}).dropna(subset=["email"])
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path