In [1]:
import numpy as np
from scipy import stats
In [2]:
import urllib.request as request
file = request.urlopen('https://raw.githubusercontent.com/lidimayra/basic-stats/master/frequencies/pokemons.txt')
print(file)
In [3]:
pokemons = file.read().decode('UTF-8')
In [4]:
file.close()
In [5]:
print(pokemons)
In [6]:
pokemons_list = pokemons.split()
In [7]:
pokemons_list[6]
Out[7]:
In [8]:
pokemons_list[7]
Out[8]:
In [9]:
pokemons_list[8]
Out[9]:
In [10]:
stats.mode(pokemons_list)[1]
Out[10]:
In [11]:
frequencies = stats.itemfreq(pokemons_list)
print(frequencies)
In [12]:
type(frequencies)
Out[12]:
In [35]:
xi = frequencies[:, 0]
print(xi)
In [36]:
fi = frequencies[:, 1]
print(fi)
In [37]:
fi = fi.astype(int)
print(fi)
In [38]:
np.arange(10)
Out[38]:
In [39]:
len(xi)
Out[39]:
In [82]:
%matplotlib notebook
import matplotlib.pyplot as plt
size = len(xi)
x_location = np.arange(size)
plt.bar(x_location, fi, align='center')
Out[82]:
In [29]:
size = len(xi)
print(size)
In [33]:
x_location = np.arange(size)
print(x_location)
In [83]:
plt.xticks(np.arange(size), xi)
Out[83]:
In [84]:
plt.ylim(0, max(fi) + 0.5)
Out[84]:
In [ ]: