Find out the percentage of missing values in each column in the given dataset

前端 未结 11 1259
逝去的感伤
逝去的感伤 2021-01-31 08:38
import pandas as pd
df = pd.read_csv(\'https://query.data.world/s/Hfu_PsEuD1Z_yJHmGaxWTxvkz7W_b0\')
percent= 100*(len(df.loc[:,df.isnull().sum(axis=0)>=1 ].index) / l         


        
11条回答
  •  甜味超标
    2021-01-31 09:35

    The solution you're looking for is :

    round(df.isnull().mean()*100,2) 
    

    This will round up the percentage upto 2 decimal places

    Another way to do this is

    round((df.isnull().sum()*100)/len(df),2)
    

    but this is not efficient as using mean() is.

提交回复
热议问题