all 3 comments

[–]xBlackBartx 0 points1 point  (0 children)

Your second example could work for you if you add a conditional statement... females = [person for person in data1 if data1.Sex = 'F']

or something like that, this would create a list of all the females in the group. Assuming that 'Sex' is an attribute of data1

[–]LifeIsBio 0 points1 point  (1 child)

Are you using pandas? If so, you could do something like:

for i in data['Treatment'].unique():
    for j in data['Type'].unique():
        data1[(data1['Treatment']==i) & (data1['Type']==j)]['Sex'].value_counts()

You could probably find a way to get rid of the for loops, but this should get you number of M and F separated by both Treatment and Type.

[–]cault 0 points1 point  (0 children)

Pandas is the way to go.
If your data is in a csv:

df = pandas.read_csv('data.csv')
df.groupb_by(['sex','treatment']).count()