Any Pandas dataframe experts? Support/Resistance code

In that link, you will find a function that returns a series of supports and resistances for a given datasets of lows and highs.

Every single time I try to use this, the data returned is always empty. I isolated it to a ‘SettingWithCopyWarning’ issue that arises at line 76 and 78 of that file (when trying to set a value at the index of df[‘sup’] and df[‘res’].)

Anyone understand how to set values to dataframes without that error? If I remove the x and put a single integer, it will actually write to the index location. Would appreciate some help.

Hi,
ran the code. it has a lot of NaNs because that’s what it does when no resistane or support, but it seems to work
no issue with df['sup'].iloc[x] = sup

here’s a code example

api = tradeapi.REST(key_id=ALPACA_API_KEY,
                    secret_key=ALPACA_SECRET_KEY)
NY = 'America/New_York'
df = api.get_barset('AAPL', '1Min', start=pd.Timestamp('2020-09-26', tz=NY).isoformat(), end=pd.Timestamp('2020-09-30', tz=NY).isoformat()).df
print(supres(df['AAPL']['low'], df['AAPL']['high'])[456:])

this is what I get:
image

EDIT: Had a dumb issue on my end, it seems to work now.

Hope someone finds that code worthwhile!