データフレームがあり、値の範囲でフィルタリングまたはビン化してから、各ビンの値のカウントを取得したいと思います。
現在、私はこれを行っています:
x = 5
y = 17
z = 33
filter_values = [x, y, z]
filtered_a = df[df.filtercol <= x]
a_count = filtered_a.filtercol.count()
filtered_b = df[df.filtercol > x]
filtered_b = filtered_b[filtered_b <= y]
b_count = filtered_b.filtercol.count()
filtered_c = df[df.filtercol > y]
c_count = filtered_c.filtercol.count()
しかし、同じことを達成するためのより簡潔な方法はありますか?