-1

I am trying to plot a graph for "Occurances of an IP" vs "IP" address itself. So far I have tried plotting this using excel but I want to automate this entire process, using python. The data I have is as follows.

5122 172.20.10.2 2419 74.125.103.105 1677 74.125.158.169 252 216.58.196.78 116 216.58.196.68 72 172.20.10.1 38 216.58.220.162 34 216.58.196.65 22 216.58.196.67 21 42.106.128.49 18 216.58.203.163 15 172.217.163.194 14 66.117.28.68 14 216.58.203.170 14 216.58.199.130 13 151.101.1.69 12 216.58.196.66 12 117.18.237.29 11 172.217.27.214 10 216.58.196.70 10 157.240.16.20 10 157.240.16.16 9 151.101.129.69 8 192.0.73.2 8 172.217.166.78 8 104.69.158.16 8 104.16.109.18 4 139.59.43.68 2 172.20.10.3 2 14.139.56.74

So far I have tried various of ways to plot this via storing it in an array and using python but I just can't make it work.

Little nudge would be really helpful.

1 Answers1

1

With your data in a pandas dataframe with column names "ip" and "count", try this:

import seaborn as sns
import matplotlib.pyplot as plt
sns.barplot(x = "ip", y = "count", data = data)
plt.show()
Will
  • 151
  • 6
  • Oh and your data covers a pretty wide range, maybe scale the y-axis logarithmically using something like this: https://stackoverflow.com/questions/27019153/how-to-scale-seaborns-y-axis-with-a-bar-plot#27107856 – Will Jun 09 '18 at 16:54
  • How would you access the data? – Coding_Karma Jun 09 '18 at 17:20
  • I just copy/pasted the data you had in your post into a text file and then accessed it using the pandas read_csv() method. – Will Jun 09 '18 at 17:43