Shabin K
Shabin K

Reputation: 1

Finding average by grouping row values pandas dataframe

data=df.groupby('Term')['Subject'].apply(tuple)

I wrote this line in python but I didn't achieved desired output. Can anyone help me out.

I tried many grouping methods but I never came up with the output.

Upvotes: 0

Views: 59

Answers (1)

Mat.B
Mat.B

Reputation: 376

If you are looking at the average of the Subject column grouped by Term, you were actually quite close:

df.groupby('Term')['Subject'].mean()

Upvotes: 1

Related Questions