Reputation: 5184
I have a pandas frame called df, I wish to select only the rows which have some conditions.
I have one column called 'Country' and one called 'Type'.
I want to select all the rows in which the 'Country' says "South Korea" and the 'Type' is not empty.
I tried the following code df = df[df['Country'] == 'South Korea' & ~df['Type'].empty()]
But I get the following error, TypeError: 'bool' object is not callable
. How do I select the rows with the conditions I want?
Upvotes: 0
Views: 56
Reputation: 153460
Try using paranthesis and notna
:
df = df.loc[(df['Country'] == 'South Korea') & (df['Type'].notna())]
Upvotes: 1