0
我嘗試了幾種不同的方法來存儲返回嵌入在for循環中的熊貓數據框對象的'pandas-datareader'函數的結果。儘管使用了df.append方法,輸出仍會繼續覆蓋。此外,如果可能的話,抑制隨後調用DataReader函數的頭並僅保留數字輸出將是有益的。將for循環的結果附加到熊貓數據框中
for e in eqy[0:5]:
try:
prices = web.DataReader(e, 'google', start, end)
prices = pd.DataFrame.append(prices)
except:
pass
print prices
嘗試追加數據框到Python列表。然後用'pd.concat()'將外部循環連接列表複製到最終的數據框中。 – Parfait