In [19]:
from scipy import stats
In [4]:
import urllib.request as request
file = request.urlopen('https://raw.githubusercontent.com/lidimayra/basic-stats/master/frequencies/pokemons.txt')
print(file)
In [5]:
pokemons = file.read().decode('UTF-8')
In [9]:
file.close()
In [10]:
print(pokemons)
In [11]:
pokemons_list = pokemons.split()
In [12]:
pokemons_list[6]
Out[12]:
In [13]:
pokemons_list[7]
Out[13]:
In [14]:
pokemons_list[8]
Out[14]:
In [71]:
stats.mode(pokemons_list)[1]
Out[71]:
In [72]:
frequencies = stats.itemfreq(pokemons_list)
print(frequencies)
In [80]:
type(frequencies)
Out[80]:
In [73]:
xi = frequencies[0:0, 0]
print(xi)
In [74]:
fi = frequencies[:, 1]
print(fi)
In [75]:
fi = fi.astype(int)
print(fi)
In [76]:
%matplotlib notebook
import matplotlib.pyplot as plt
x_pos = np.arange(len(xi))
plt.figure(1)
plt.bar(x_pos, fi, align='center')
plt.ylim(0, max(fi) + 0.5)
plt.xticks(np.arange(len(xi)), xi)
plt.show()
In [ ]: