Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python, Pandas : Return only those rows which have missing values

People also ask

How do you get rows with missing values in pandas?

You can extract rows/columns containing missing values from pandas. DataFrame by using the isnull() or isna() method that checks if an element is a missing value.

How do I show only null values in pandas?

In order to check null values in Pandas DataFrame, we use isnull() function this function return dataframe of Boolean values which are True for NaN values.


You can use any axis=1 to check for least one True per row, then filter with boolean indexing:

null_data = df[df.isnull().any(axis=1)]

df.isnull().any(axis = 1).sum()

this gives you the total number of rows with at least one missing data


If you want to see only the rows that contains the NaN values you could do:

data_frame[data_frame.iloc[:, insert column number here]=='NaN']