我希望绘制一个直方图来检查用于数据挖掘的 IP 地址的出现频率。我的片段:-import pandas as pdimport matplotlib.pyplot as pltp1 = r'small_set.csv'd = pd.read_csv(p1, engine='python')source_ip = d['Source IP']source_ip.hist()我的“source_ip”是一个熊猫系列类型变量,如下所示:->>> source_ip0 8.0.69.01 8.0.69.02 8.0.69.03 8.0.69.04 8.0.69.05 8.0.69.0 ... 69 192.168.10.1770 192.168.10.1771 192.168.10.1772 192.168.10.1773 192.168.10.1774 192.168.10.17Name: Source IP, Length: 74, dtype: object但是在 line source_ip.hist(),我收到以下错误:-File "/home/developer/.local/lib/python2.7/site-packages/numpy/lib/histograms.py", line 253, in _get_outer_edges "supplied range of [{}, {}] is not finite".format(first_edge, last_edge))ValueError: supplied range of [inf, 8.0.69.0] is not finite作为一种解决方法,我找到了使用value_counts()如下的频率计数:-s = d['Source IP'].value_counts()>>> s8.0.69.0 28192.168.10.17 26192.168.10.12 25192.168.10.19 12192.168.10.50 8Name: Source IP, dtype: int64但它仍然不一样。如何摆脱该值错误并显示合法的直方图?
添加回答
举报
0/150
提交
取消