I retrieve data from binance. In my dataframe I have historical data from the last hour in minute bars. I also have a column with the live avg price (df.price_line). This column has the live price on all rows.
time high low close atr sma signal ROC price_line distance volatility
50 2021-07-03 10:54:00 2196.00 2199.65 2195.01 3.505200 2191.8358 - 0.213209 2205.6 NaN NaN
51 2021-07-03 10:55:00 2198.86 2199.81 2196.82 3.597686 2191.9582 - 0.438913 2205.6 NaN NaN
52 2021-07-03 10:56:00 2197.14 2197.14 2195.14 3.363565 2192.0720 - 0.365774 2205.6 NaN NaN
53 2021-07-03 10:57:00 2195.52 2197.50 2195.00 3.291882 2192.1594 - 0.352032 2205.6 NaN NaN
54 2021-07-03 10:58:00 2197.44 2197.44 2195.15 3.231033 2192.2454 - 0.313945 2205.6 NaN NaN
55 2021-07-03 10:59:00 2196.97 2197.33 2195.67 3.155960 2192.3506 - 0.200797 2205.6 NaN NaN
56 2021-07-03 11:00:00 2195.96 2198.00 2195.91 3.096962 2192.4422 - 0.088880 2205.6 NaN NaN
57 2021-07-03 11:01:00 2197.00 2199.88 2196.65 3.159322 2192.5432 - 0.107552 2205.6 NaN NaN
58 2021-07-03 11:02:00 2198.94 2201.99 2198.01 3.315085 2192.6034 - 0.121165 2205.6 NaN NaN
59 2021-07-03 11:03:00 2201.31 2215.79 2201.30 4.348293 2192.7606 - 0.241348 2205.6
In the last row the close price is based on the minute data. The price line updates with the websocket data from binance in seconds intervals.
How can I update the last df.close row (# 59) in real time based on df.price_line?
I tried it like this:
df['close'].iloc[-1] = df.price_line
But I get a warning and the df is not working:
a value is trying to be set on a copy of a slice from a dataframe
When I suppress the warning the dataframe is not working either
How to make it work?