I have a Dataframe as the following:
import pandas as pd
data = {'gender': ['female', 'female', 'female', 'male', 'male'], 'race': ['group B', 'group C', 'group B', 'group A', 'group C'], 'parental level of education': ["bachelor's degree", 'some college', "master's degree", "associate's degree", 'some college'], 'lunch': ['standard', 'standard', 'standard', 'free/reduced', 'standard']}
df = pd.DataFrame(data)
# display(df)
gender race parental level of education lunch
0 female group B bachelor's degree standard
1 female group C some college standard
2 female group B master's degree standard
3 male group A associate's degree free/reduced
4 male group C some college standard
Q: I want to find a way to count how many female in each group (race column) separately.
I used 'groupby('gender').count()'
, but it counts how many male and female in the entire data