-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph-creation.py
42 lines (28 loc) · 999 Bytes
/
graph-creation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def load_data(filename):
"""Captura os valores da planilha excel e converte em uma matrix -- Retona um objeto do tipo np.array()"""
data = pd.read_excel(filename)
matrix = data.to_numpy(copy=True)
return matrix
pd.set_option('display.max_rows', None)
data = load_data("megasena-results.xlsx")
v_dict = {}
k_values = []
v_values = []
for c in range(0, 60):
f = np.count_nonzero(data == c) # Se quiser acessar uma coluna, substitua "data" por data[:, número da coluna]
v_dict[c] = f
for k, v in v_dict.items():
k_values.append(k) # x
v_values.append(v) # y
plt.xlabel("Números das Casas")
plt.ylabel("Quantidade de repetições")
plt.title("Números X Frequência - Geral")
x_points = np.array(k_values)
y_points = np.array(v_values)
plt.plot(x_points, y_points)
plt.xticks(np.arange(min(x_points), max(y_points), 2))
plt.grid()
plt.show()