I want to call df['item'].value_counts()
and, with minimal manipulation, end up with a dataframe with columns item
and count
.
I can do something like this:
df['item'].value_counts().reset_index().rename(columns={"item":"count", "index": "item"})
... which is fine but I'm like 95% sure there is a cleaner way to do this by passing a variable to reset_index
or something similar