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

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

    To cover all missing values and round the results:

    ((df.isnull() | df.isna()).sum() * 100 / df.index.size).round(2)
    

    The output:

    Out[556]: 
    Ord_id                 0.00
    Prod_id                0.00
    Ship_id                0.00
    Cust_id                0.00
    Sales                  0.24
    Discount               0.65
    Order_Quantity         0.65
    Profit                 0.65
    Shipping_Cost          0.65
    Product_Base_Margin    1.30
    dtype: float64
    

提交回复
热议问题