i have a strange problem.
I get some datas like this :
save_last_row = exchange.fetch_ohlcv('BTC/USD', timeframe='1m', limit=2)
save_last_row = pd.DataFrame(save_last_row[:-1],columns=['Date Time', 'Open', 'High', 'Low', 'Close', 'Volume'])
The data looks like that :
Date Time Open High Low Close Volume
0 1640190840000 49075.0 49085.0 49044.0 49071.0 147792.0244
It is a loop so i get the last line every loop. Strangely, when i do that after :
last_row = save_last_row
last_row = function_convert(last_row)
i obtain that for last_row :
Date Time Open High Low Close Volume
0 2021-12-22 17:41:00 49041.0 49073.0 49029.0 49033.0 136169.2562
We can see the date time is not in the same format. And if i printf the save_last_row (that i didn't modify), i have :
Date Time Open High Low Close Volume
0 2021-12-22 17:41:00 49041.0 49073.0 49029.0 49033.0 136169.2562
WHY ???? Last_row get just the data from save_last_row. how the variable save_last_row could be modify ???
NB : and the function_convert just modify some values :
def conversion_date(df):
df["Date Time"] = df["Date Time"] + 3600000 # add one hour to have local time
df["Date Time"] = (df["Date Time"].apply(parse_dates)) # convert
return df
EDIT : the variable last_row is converted (ok), but save_last_row also !!! (and it is not ok, i didn't convert it) so why ??
EDIT2 : use save_last_row.copy() thank you Chris Doyle