We can use pd.cut to bin the values into ranges, then we can groupby these ranges, and finally call count to count the values now binned into these ranges:In [82]:df = pd.DataFrame({"a": np.random.random_integers(0, high=100, size=100)})ranges = [0,10,20,30,40,50,60,70,80,90,100]df.groupby(pd.cut(df.a, ranges)).count()Out[82]: aa (0, 10] 10(10, 20] 6(20, 30] 12(30, 40] 9(40, 50] 11(50, 60] 12(60, 70] 9(70, 80] 13(80, 90] 9(90, 100] 9 这篇关于 pandas groupby如何计算范围内的计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-27 07:38