1

Trying to only keep the rows in my data frame that are equal to certain string values.

I've tried to do it a few ways but keep running to errors:

curr = curr[curr['Technology'] == 'Solar Photovoltaic'] | curr[curr['Technology'] == 'Solar Thermal without Energy Storage'] | curr[curr['Technology'] == 'Solar Thermal with Energy Storage']

Gives error: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

curr = curr[curr['Technology'] == 'Solar Photovoltaic'] or curr[curr['Technology'] == 'Solar Thermal without Energy Storage'] or curr[curr['Technology'] == 'Solar Thermal with Energy Storage']

Gives error: unsupported operand type(s) for |: 'str' and 'bool'

  • 4
    use parenthesis also dont filter the dataframe for every results: `df[(df['column']=='a)|(df['column']=='b)|..)]` or you can just use `isin` here `df[df['column'].isin(['a','b','c'])]` – anky Jan 10 '20 at 03:55

0 Answers0