ant to try multiple condition parameters with OR
df[‘A’] = np.where (df[‘B’] == ‘Value1’,df[‘X’].str[:5],”)
this code works, but when I add OR ( | ) , the same logic does not work. I need to use multiple value assignment to assign the new value.
df[‘A’] = np.where (df[‘B’] == ‘Value1’ | df[‘B’] == ‘Value2’ | df[‘B’] = ‘Value3’,df[‘X’].str[:5],”)
I get TypeError: unsupported operand type(s) for |: ‘bool’ and ‘str’
TypeError: Cannot perform 'ror_' with a dtyped [object] array and scalar of type [bool]
New contributor
Arthur Samson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.