In my dataframe I have a column containing numbers, some positive, some negative. Example
Amount
0 -500
1 659
3 -10
4 344
I want to turn all numbers Df['Amount'] into positive numbers. I thought about multiplying all numbers with *-1. But though this turns negative numbers positive, and also does the reverse.
Is there a better way to do this?
You can assign the result back to the original column:
df['Amount'] = df['Amount'].abs()
Or you can create a new column, instead:
df['AbsAmount'] = df['Amount'].abs()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With