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) / len(df.index))
print(round(percent,2))
输入是 https://query.data.world/s/Hfu_PsEuD1Z_yJHmGaxWTxvkz7W_b0
输出应该是
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
原文由 Shaswata 发布,翻译遵循 CC BY-SA 4.0 许可协议
这个怎么样?我想我以前确实在这里发现过类似的东西,但我现在没有看到它……
如果您想要对缺失的百分比进行排序,请按照上面的说明进行操作:
如评论中所述,您也可以仅使用我上面代码中的第一行,即: