March 2020
Beginner to intermediate
352 pages
8h 40m
English
One of the ways to handle missing values is to simply remove them from our dataset. We have seen that we can use the isnull() and notnull() functions from the pandas library to determine null values:
dfx.store4[dfx.store4.notnull()]
The output of the preceding code is as follows:
apple 20.0watermelon 18.0Name: store4, dtype: float64
The output shows that store4 only reported two items of data. Now, we can use the dropna() method to remove the rows:
dfx.store4.dropna()
The output of the preceding code is as follows:
apple 20.0watermelon 18.0Name: store4, dtype: float64
Note that the dropna() method just returns a copy of the dataframe by dropping the rows with NaN. The original dataframe is not changed.
If dropna() ...
Read now
Unlock full access