# 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()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter