pandas value_counts()
会忽略统计nan 但是不会忽略 true false
'''每列包含多少项nan'''
for i in df_2:
print(
df_2.loc[:,i].isna().value_counts()
)
应用
'''每列包含多少项nan'''
dict_counts = {}
for i in df_2:
if True in df_2.loc[:,i].isna().value_counts().index:
dict_counts[i] = df_2.loc[:,i].isna().value_counts().loc[True]
else:
dict_counts[i] = 0
标签:loc,false,isna,df,nan,value,忽略,counts
From: https://blog.51cto.com/u_16055028/6402339