1# Basic syntax:
2# Remove rows that have missing entries in specific column:
3df[~df['column'].isnull()]
4# Where df['Age'].isnull() returns a Series of booleans that are true
5# when 'column' has an empty row. The ~ negates the Series so that you
6# obtain the rows of df the don't have empty values in 'column'
7
8# Remove rows that have missing entries in any column:
9df.dropna()
10
11# Example usage:
12import pandas as pd
13# Create dataframe
14df = pd.DataFrame({'Last_Name': ['Smith', None, 'Brown'],
15 'First_Name': ['John', 'Mike', 'Bill'],
16 'Age': [35, 45, None]})
17
18print(df)
19 Last_Name First_Name Age
200 Smith John 35.0
211 None Mike 45.0
222 Brown Bill NaN
23
24df[~df['Age'].isnull()] # Returns:
25 Last_Name First_Name Age
260 Smith John 35.0
271 None Mike 45.0
28
29df.dropna() # Returns:
30 Last_Name First_Name Age
310 Smith John 35.0