Lesson 3 ❮ Lesson List ❮ Top Page
❯ 3.2 Handling Missing Data
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
EXPECTED COMPLETION TIME
❲▹❳ Video 4m 53s
☷ Interactive readings 5m
In this example we make a small Series to see how missing data works. Note that missing data is represented by NaN.
There are a few ways to filter out missing data. While you always have the option to do it by hand using isnull and boolean indexing, the dropna can be helpful. On a Series, it returns the Series with only the non-null data and index values.
Suppose you want to keep only rows containing a certain number of observations. You can indicate this with the thresh argument.
Rather than filtering out missing data, you may want to fill in the "holes" in any number of ways. Calling fillna with a constant replaces missing values with that value. You might also pass the mean or median value of a Series.