I am trying to clear some data. I have values that are negative, which they cannot be. And I would like to replace all the values that are negative with their corresponding positive values.
A | B | C
-1.9 | -0.2 | 'Hello'
1.2 | 0.3 | 'World'
I wish it became
A | B | C
1.9 | 0.2 | 'Hello'
1.2 | 0.3 | 'World'
At the moment, I just started writing a replace statement
df.replace(df.loc[(df['A'] < 0) & (df['B'] < 0)],df * -1,inplace=True)
Please help me in the right direction
source
share