0

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?

anarchy
  • 3,709
  • 2
  • 16
  • 48
  • Does this answer your question? [How to select rows from a DataFrame based on column values?](https://stackoverflow.com/questions/17071871/how-to-select-rows-from-a-dataframe-based-on-column-values) – mechanical_meat Apr 24 '20 at 21:55
  • i checked out this post, i keep getting errors as well – anarchy Apr 24 '20 at 21:56

1 Answers1

1

Try using paranthesis and notna:

df = df.loc[(df['Country'] == 'South Korea') & (df['Type'].notna())]
Scott Boston
  • 147,308
  • 15
  • 139
  • 187