user10718437
user10718437

Reputation:

Panda: Count Intervall

I want to Count "D" (groupby "B" and "C"). And I want as an Output: If my count is between 4 and 15: True If my count is not between 4 and 15: False But my Code does not work: df[df['A'] == True].groupby(['B', 'C'])[['D']].count() > 4 & < 15

Can you help me? Thank you!

Upvotes: 1

Views: 48

Answers (1)

jezrael
jezrael

Reputation: 862571

I believe you need Series.between with inclusive parameter:

s = df[df['A'] == True].groupby(['B', 'C'])['D'].count()

out = s.between(4, 15, inclusive=False)
print (out)

Upvotes: 1

Related Questions