Pandas: Get values from column that appear more than X times

Or how about this:

Create the table:

>>> import pandas as pd
>>> df2 = pd.DataFrame([{"uid": 0, "mi":1}, {"uid": 0, "mi":2}, {"uid": 0, "mi":1}, {"uid": 0, "mi":1}])

Get the counts of each occurance:

>>> vc = df2.mi.value_counts()
>>> print vc
1    3
2    1

Print out those that occur more than 2 times:

>>> print vc[vc > 2].index[0]
1

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)