missing values

PHOTO EMBED

Wed Jan 05 2022 11:11:56 GMT+0000 (Coordinated Universal Time)

Saved by @ahoeweler

# check for missing values in df
df.isna().any() # can also use .any().sum()

# option 2
df['col1'].isnull().sum()

# drop missing values
df.dropna()

# fill missing values
df.fillna(0)

# fill missing values with mean (or other statistical measures)
co2_mean = df['col1'].mean()
df = df.fillna({'col2': co2_mean})

# plot missing values (nice!)
import missingno as msno
import matplotlib.pyplot as plt

msno.matrix(df)
plt.show()
content_copyCOPY