I have the following dataframe:
df0: A B C Date 2017-04-13 884.669983 139.389999 46.900002 2017-04-17 901.989990 141.419998 47.389999 2017-04-18 903.780029 140.960007 47.560001 2017-04-19 899.200012 142.270004 47.000000 2017-04-20 902.059998 143.800003 47.669998 2017-04-21 898.530029 143.679993 47.520000 I am simply looking forward to create a new dataframe main_df that what does is substract the row in i+1 from the row i and turn that resulting row to absolute numbers and introduce it into a new dataframe:
Here is what I have tried:
main_df=pd.DataFrame() for i in range(len(df0)): main_df.iloc[i]=np.absolute(df0.iloc[i+1]-df0.iloc[i]) print(main_df) outputs the error single positional indexer is out-of-bounds
Which is quite confusing given that iterating with the iloc property has worked correctly in other ocasiones.
Your help would be highly appreciated.