nick_v1
nick_v1

Reputation: 1664

Pandas Filtering

I have a data frame that I am getting some counts on, like so:

t = df['NAME'].value_counts()[:10]

I would then like to reduce the original data set (df) to only include items that match t. Something like:

temp = df[t]

or

temp = df[df['NAME'] in t]

Thanks

Upvotes: 0

Views: 114

Answers (1)

HYRY
HYRY

Reputation: 97291

try this:

df[df.name.isin(t.index)]

Upvotes: 1

Related Questions