O'Reilly logo

Hands-On Data Analysis with NumPy and pandas by Curtis Miller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deleting missing information

The dropna for series and DataFrames can be useful for creating a copy of the object where rows of missing information are removed. By default, it drops rows with any missing data, and when used with a series, it eliminates elements with NaN. If you want this done in place, set the inplace parameter to true.

If we only want to remove rows that contain only missing information, and thus no information of any use, we can set the how parameter to all. By default, this method works along rows, but if we want to change it to work along columns, we can set the access argument to 1.

Here's an example of what we just discussed. Let's take this DataFrame, df, and drop any rows where missing data is present:

Notice that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required