Home > Mobile >  How to use groupby on a dataframe
How to use groupby on a dataframe

Time:12-04

I have a dataframe (survey) in which i need to groupby 2 columns. One of the 2 columns is a ranking (5 options : Very Poor, Poor, Average, Good and Excellent) and the second one is a list of times. I need to groupby both of those columns like that :

raking    |   Time   |  Count of how many times the time appears on the column "time" for a raking  
-------------------------------------
Very poor |  0.0     |   6
          |  1.0     |   2    
          |  2.0     |   9             
-------------------------------------                              
Poor      |  0.0     |   3                           
          |  1.0     |   12                          
...

I need to show the results of these table in 5 graphs (one for each raking), with x=Time and Y=Count

I've been stuck for a few hours now, can someone help???

CodePudding user response:

Setup a enter image description here

CodePudding user response:

Try:

df.groupby(['ranking','Time'])['Time'].count()
  • Related