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

前端 未结 11 1170
逝去的感伤
逝去的感伤 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:24

    import numpy as np
    
    import pandas as pd
    
    df = pd.read_csv('https://query.data.world/s/Hfu_PsEuD1Z_yJHmGaxWTxvkz7W_b0')
    
    df.loc[np.isnan(df['Product_Base_Margin']),['Product_Base_Margin']]=df['Product_Base_Margin'].mean()
    
    print(round(100*(df.isnull().sum()/len(df.index)), 2))
    

提交回复
热议问题