0

I have dataframe with two numerical float values. I want to do some math based on those columns values to calculate new columns.

those are the calculation I want to do:

df['calc1']=(df['col1']**(0.5))/(df['col2']**2)

df['calc2']=(df['col1']**(df['col2']))/(df['col2']**(df['col1']))

The problem is that those calculations create NaN values. I have tried to use sqrt :

(np.sqrt((df['col1']))/(df['col2']**2))

but that also created NaN.
I also tried to change the 0.5 to 1/2 but the same.

What do I do wrong?

edit: example:

>>>col1    col2
0  -6.14   -15.12
1  -6.12   -7.9
2  -6.12   -7.94
...
Reut
  • 1,555
  • 4
  • 23
  • 55

0 Answers0