value_counts to list 1

value_counts to list

df[column].value_counts()

# get indexes
df[column].value_counts().index.tolist()

# get values of occurrences
df[column].value_counts().values.tolist()

Here is what the above code is Doing:
1. df[column].value_counts() – this is a pandas series that contains the counts of each value in the column
2. df[column].value_counts().index.tolist() – this is a list of the indexes of the series
3. df[column].value_counts().values.tolist() – this is a list of the values of the series

Similar Posts