Trying to run a back testing . have written below code +++ train.loc[:, 'Date'] = pd.to_datetime(train.index) # Fix here with .loc[] train.set_index('Date', inplace=True) +++ but getting below error. 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 could you explain why i am getting this error ?