pandas统计每一列缺失值函数
#查找缺失值函数
def find_nan(df):
all_count=len(sh_car)
nan_lists={}
for col in df.columns:
if df[col].isnull().sum():
nan_lists[col]=df[col].isnull().sum()
for k,v in nan_lists.items():
print('变量 "{}" \t 共有 {} 笔缺失值\t 占比为 {:.4f}%'.format(k,v,v/all_count))
感谢
https://www.jianshu.com/p/9f583668f386
def check_missing_data(df):
return df.isnull().sum().sort_values(ascending=False)