Skip to content
Advertisement

Counts for unique values in pandas

I want to find counts for unique values. Goal is to have df having df.a.value_counts().unique() in one column and in next column their counts.

JavaScript

.

JavaScript

.

JavaScript

.

JavaScript

.

JavaScript

Goal

JavaScript

Advertisement

Answer

Apply value_counts once more:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement