dimanche 26 mai 2019

Error - Trying to fill dataframe with the result of a For Loop with If statement

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.

Aucun commentaire:

Enregistrer un commentaire