Dylan Meeus
Dylan Meeus

Reputation: 5802

pandas filter by values in 2 columns, return entire row

I've looked around multiple questions on here and no solution works. I have a matrix, where I want to filter values in 2 columns and return the entire row where this filter applies.

At the moment I have tried:

mask = (data['sender'] == 'me') & (data['status'] == 'done') data[mask] which makes all values become "NaN".

When I try to apply the mask seperately, I get a DataFrame that contains the correct value in the location, but with all other columns as NaN.

I had also tried a different approach, namely like so:

data.loc[data['sender' == 'me'] which has the same result of turning every value in NaN except for the Row x Column where the value appears..

Upvotes: 1

Views: 699

Answers (1)

kerastf
kerastf

Reputation: 509

Hope this helps

    k=pd.DataFrame()
    k=data[(data['sender'] == 'me') & (data['status'] == 'done')]
    k.head()

Upvotes: 2

Related Questions