Nelly Louis
Nelly Louis

Reputation: 167

Group and represent pie chart

I have a Dataframe like this:

Hours  Person

10     Jack
20     Louis
10     Jack
30     Anne
10     Anne

And I want to represent this data as a pie chart where 50% of the hours belongs to Anne, 25% to Jack an 25% to Louis. I have tried with goupby but it doesn´t represent what I want.

Upvotes: 0

Views: 26

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150745

Try:

df.groupby('Person')['Hours'].sum().plot.pie(autopct='%.2f')

Output:

enter image description here

Upvotes: 1

Related Questions