When is it appropriate to use df.value_counts() vs df.groupby('…').count()?
问题 I\'ve heard in Pandas there\'s often multiple ways to do the same thing, but I was wondering – If I\'m trying to group data by a value within a specific column and count the number of items with that value, when does it make sense to use df.groupby(\'colA\').count() and when does it make sense to use df[\'colA\'].value_counts() ? 回答1: There is difference value_counts return: The resulting object will be in descending order so that the first element is the most frequently-occurring element.