I have a df in pandas, python with mostly float values but contains a few strings and looks as such:
index cashflow date changeinvalue
0 5000 2019-12-31 9300
1 4000 2019-12-31 -4000
2 -2000 2019-12-31 -9000
I am trying to use an apply function and lambda function to turn all values in the dataframe to absolute values. However I think I may be using the lambda function incorrectly as using the following code I get the following error:
df.apply(lambda x: abs(x) if isinstance(x, str) == False else pass)
SyntaxError: invalid syntax
Would anyone be able to help me? Thanks