且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

python pandas:如何根据列中的每个值进行分组并计数?

更新时间:2022-12-10 21:20:13

try:

try:

df['group'].value_counts()['a']

切勿在熊猫中使用循环。它效率低下,通常会重新创建包中的某些现有功能。

in general, you should NEVER use for loops in pandas. it's inefficient and usually recreating some existing functionality in the package.