Reputation: 18197
I was trying to build a new dataframe based on selection criteria from the first dataframe.
df_selected = df_in.loc[ (df_in['featureclass'] == 'P' | df_in['featureclass'] == 'A') &
(df_in['admin1code'] == 'TX')
]
returns this error:
TypeError: unsupported operand type(s) for |: 'str' and 'str'
Upvotes: 0
Views: 782
Reputation: 18197
Need to wrap each boolean in it's own set of parentheses.
df_selected = df_in.loc[ ((df_in['featureclass'] == 'P') | (df_in['featureclass'] == 'A')) &
(df_in['admin1code'] == 'TX')
]
Upvotes: 1