I know they were a number of question on this warning. I read all and still could figure it out why this line gives me the warning:
This is the function I tried to call:
def createFeature(df):
df.loc[:, 'PCT_change'] = (df.loc[:, 'Close'] - df.loc[:, 'Close'].shift(1))/df.loc[:, 'Close'].shift(1)*100.0
return df
When I called the above function with this command:
stock_train_reform = createFeature(stock_train)
The warnings appear as
stock_train_reform = createFeature(stock_train) /Applications/Spyder.app/Contents/Resources/lib/python3.5/pandas/core/indexing.py:560: 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 don't know how to fix this warning. Please help Thanks a lot.