find rows that have null values in column pandas code example
Example 1: show rows with a null value pandas
df1 = df[df.isna().any(axis=1)]
Example 2: pandas return rows that don't have null
df[~df['column'].isnull()]
df.dropna()
import pandas as pd
df = pd.DataFrame({'Last_Name': ['Smith', None, 'Brown'],
'First_Name': ['John', 'Mike', 'Bill'],
'Age': [35, 45, None]})
print(df)
Last_Name First_Name Age
0 Smith John 35.0
1 None Mike 45.0
2 Brown Bill NaN
df[~df['Age'].isnull()]
Last_Name First_Name Age
0 Smith John 35.0
1 None Mike 45.0
df.dropna()
Last_Name First_Name Age
0 Smith John 35.0