A).从全局df(Pardon Dataframe)获得真实数据. B).将数据更新为临时DCT(Gd_Tick_G1). C).扩展列表
问:为什么函数只扩展相同的数据(最后一个循环数据)? 谢谢.
global df, gl_price_vol
gd_tick_g1 = {'AmountSum': [2116248500.0], 'Close': [50.1], 'Date': '2022/10/07', 'TickType': [2], 'Time': '09:11:41.107750', 'VolSum': [60000], 'Volume': [9]}
lens = len(df)
print(lens)
for i in range(lens-1, -1, -1):
#(lens-1)~0, ex.lens=10, 9~0
gl_price_vol.extend([2498])
tick_type = df.iat[i,5] + df.iat[i,6]
if tick_type == (-1):
tick_type = 2
gd_tick_g1['AmountSum'] = [i] #test
gd_tick_g1['Close'] = df.iat[i,3] #d1
gd_tick_g1['Date'] = '2022/10/07'
gd_tick_g1['TickType'] = [tick_type] #d2
gd_tick_g1['Time'] = '09:11:41.107750'
gd_tick_g1['VolSum'] = 60000
gd_tick_g1['Volume'] = [df.iat[i,4]] #d3
#print(gd_tick_g1) #confime:update ok!
gl_price_vol.extend({gd_tick_g1.values()}) #question: only extend the same data (the last loop data)
[2498, Dict_values([[0],49.05,‘2022/10/07’,[2],‘09:11:41.107750’,60000,[147]]);
2498, DICT_VALUES([[0],49.05,‘2022/10/07’,[2],‘09:11:41.107750’,60000,[147]),...
(所有相同的最后循环数据) ]