Warning pandas, 2 loopings!

Asked

Viewed 84 times

0

Guys I’m having trouble with this looping, because it’s a situation that I can’t solve with np.where, why does the DataFrame to find the value of the gain or loss from another condition, which comes first.

It’s working but I keep getting this Warning:

C:\Users\Jair\Anaconda3\lib\site-packages\ipykernel_launcher.py:14: 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
def estrategia_2_alta(candles):

    for i in range(1,len(candles)):
        if candles['Twintower'][i]== 1:
            loop2 = i
            for twin in range(loop2+1, len(candles)):
                if candles['askclose'][twin]>=candles['Gain'][i]:

                    candles['Resultado'][i] = candles['Tamanho_Twin'][i]*GainC
                    break

                elif candles['askhigh'][twin]>=candles['Gain'][i]:

                    candles['Resultado'][i] = candles['Tamanho_Twin'][i]*GainC
                    break

                elif candles['askclose'][twin]<=candles['Loss'][i]:
                    candles['Resultado'][i] = candles['Tamanho_Twin'][i]*(-StopC)
                    break

                elif candles['asklow'][twin]<=candles['Loss'][i]:

                    candles['Resultado'][i] = candles['Tamanho_Twin'][i]*(-StopC)
                    break

Dataframe

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.