Home > database >  how to divide a row with the previous one and that the values remain in a new column?
how to divide a row with the previous one and that the values remain in a new column?

Time:11-07

My problem is that I have time series, and I need to create a new column that gives me the natural logarithm of today's price divided by yesterday's price, and that these values are in a new column

#Accion1['Rentabilidad1'] = Accion1.apply(lambda row: np.log(Promedio), axis=1)
Accion1['Rentabilidad'] = np.log(Accion1['Promedio'])
Accion1

enter image description here

I was thinking of creating new variables and splitting iloc[0]/iloc[1] but it doesn't work either, please help

  • Related