0

I'm working on the following dataset:

dataset

and I want to count each value in the LearnCode column for each Age category, I've tried doing it using Groupby method but didn't manage to get it correctly, can anyone help on how to do it?

Abde
  • 21
  • 5

1 Answers1

1

You can do this using a groupby on two columns

results = df.groupby(by=['Age', 'LearnCode']).count()

This outputs a count for each ['Age', 'LearnCode'] pair

NickHilton
  • 662
  • 6
  • 13