如何在数据框架中绘制缺失值的分布
我有一个带有100列的数据框架,想通过绘制图来研究缺失值的比例。
我能够使用以下代码:
代码:
missing_data_in_df=pd.DataFrame({'NaN_Counts': df.isna().sum(), 'NaN_Proportions(%)': (df.isna().sum() / df.shape[0]) * 100}).sort_values(by='NaN_Counts', ascending=False)
missing_data_in_df.head()
输出:
NaN_Counts NaN_Proportions(%)
Col1 889061 99.757636
Col2 685843 76.955435
Col3 584612 65.596749
Col4 476524 53.468668
Col4 392318 44.020282
尝试使用直方图可视化 -
代码:
missing_data_in_df.hist()
获取
我将输出AS -https ://i.sstatic.net/7yndt 。 png“ rel =” nofollow noreferrer“>
是否有任何方法可以获取任何方法X轴的数据框?
I have a data frame with 100's of column and would like to investigate the proportion of missing values by plotting graph.
I'm able to get the proportion using below code :
Code :
missing_data_in_df=pd.DataFrame({'NaN_Counts': df.isna().sum(), 'NaN_Proportions(%)': (df.isna().sum() / df.shape[0]) * 100}).sort_values(by='NaN_Counts', ascending=False)
missing_data_in_df.head()
Output :
NaN_Counts NaN_Proportions(%)
Col1 889061 99.757636
Col2 685843 76.955435
Col3 584612 65.596749
Col4 476524 53.468668
Col4 392318 44.020282
Now when trying to visualize using histogram -
Code :
missing_data_in_df.hist()
I'm getting output as -
Is there any way to get feature names of dataframe in x-axis ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用您的dataFrame:
这是一种方法:
ouput:
With your dataframe:
Here is one way to do it:
Ouput: