input DF:
value1, value2
123L, 20
222S, 10
222L, 18
I want to make values in volumn value2
where in value1
is L
letter negative, so I am trying to multiply them by -1
expexted result:
value1, value2
123L, -20
222S, 10
222L, -18
my code
if np.where(DF['value1'].str.contains('L', case=False)):
DF['value2'] = DF['value2'] * -1
but in output i am receiving all values in column value2
negative.
How to implement this conditions only for selected rows ?
thanks