0

I have a dataframe where the last row has a Nan

something like

   A,B,C
94,35.8621497534,139.8811398413,23.075931722607212
95,35.8621915301,139.8811617064,23.013675634522304
96,35.8622333249,139.8811835151,22.93392191824463
97,35.8622751476,139.881205254,22.98818503390619
98,35.8623169559,139.8812270428,23.12554949571689
99,35.8623587254,139.8812489567,23.269025725355807
100,35.8624004417,139.8812709946,23.080210277956407
101,35.8624422121,139.881292861,Nan

I am trying to change that Nan to the previous row value (23.080210277956407) but I cannot do it I get an error

SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

I have tried several methods like

rowi=df.shape[0]
df.iloc[row-1]['C']=df.tail(2)['C'].iloc[0]

but this does not modify anything

How can I set the last value of column 'C' to be the same as the previous value?

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150

0 Answers0