Working with the Wine Review Data from Kaggle here. I am able to return the number of occurrences by variety using value_counts()
However, I am trying to find a quick way to limit the results to varieties and their counts where there is more than one occurrence.
Trying df.loc[df['variety'].value_counts()>1].value_counts()
and df['variety'].loc[df['variety'].value_counts()>1].value_counts()
both return errors.
The results can be turned into a DataFrame and the constraint added there, but something tells me that there is a way more elegant way to achieve this.
@wen ansered this in the comments.
df['variety'].value_counts().loc[lambda x : x>1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With