Ошибка - Попытка заполнить фрейм данных результатом цикла For Loop with If - PullRequest
0 голосов
/ 27 мая 2019
seq = list(range(0,len(zscore1['value'])))

Data2['PosMicrosoft'] = 0
Data['PosApple'] = 0

for i in seq:
    if idx[i] == 'True' and zscore1['value'][i] > 0:
        Data2['PosMicrosoft'][i]=-1
        Data['PosApple'][i]=1
    elif idx[i] == 'True' and zscore1['value'][i] < 0:
        Data2['PosMicrosoft'][i]=1
        Data['PosApple'][i]=-1
    else:
        Data2['PosMicrosoft'][i] = Data2['PosMicrosoft'][i]
        Data['PosApple'][i] = Data['PosApple'][i]

Вот ошибка:

C:\Users\Tomas\Anaconda3\lib\site-packages\ipykernel_launcher.py:9: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  if __name__ == '__main__':
C:\Users\Tomas\Anaconda3\lib\site-packages\ipykernel_launcher.py:10: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  # Remove the CWD from sys.path while we load stuff.
...