1

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?

0

2 Answers 2

2

This should work:

df.groupby(['result']).size().plot(kind='bar')

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

You have made error in using groupby function. Try this

graph = df.groupby(['results'])['results'].count()
graph.plot(kind = 'bar')

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.