Reputation: 35
I have a .txt file named Results.txt which contains a list as below
[100.0, 95.42, 97.31, 95.42, 95.17, 95.17, 95.35, 96.24, 95.48]
I used the Pandas read_csv function to read the .txt file and make the list into a DataFrame.
dd = pd.read_csv('Results.txt')
df = pd.DataFrame(result)
df.columns = ['Results']
df
And this is the result
Out[6]:
Results
0 100.00
1 95.42
2 97.31
3 95.42
4 95.17
5 95.17
6 95.35
7 96.24
8 95.48
What I know that i need to use groupby function for my DataFrame before plotting a graph for it but it returns me an error.
graph = df.groupby('Results').count()
plt.plot(graph)
plt.show()
ZeroDivisionError: integer division or modulo by zero
Is there anything that i missed or did wrongly before plotting the graph?
Upvotes: 1
Views: 649
Reputation: 323
You have made error in using groupby function. Try this
graph = df.groupby(['results'])['results'].count()
graph.plot(kind = 'bar')
Upvotes: 0