我試圖用Python下載Apple的股票價格。我注意到數據不在數據框中。當我在Spyder IDE中查看它時,它很混亂。如何將它強制轉換爲數據框/矩陣格式,以及如何引用數據列,如「卷」「調整關閉」?我很感謝你的幫助。Python中的數據框
import ystockquote as ys
aapl=ys.get_historical_prices("aapl","2010-01-01","2015-01-01")
我試圖用Python下載Apple的股票價格。我注意到數據不在數據框中。當我在Spyder IDE中查看它時,它很混亂。如何將它強制轉換爲數據框/矩陣格式,以及如何引用數據列,如「卷」「調整關閉」?我很感謝你的幫助。Python中的數據框
import ystockquote as ys
aapl=ys.get_historical_prices("aapl","2010-01-01","2015-01-01")
不知道你有數據的格式,但你可以像這樣創建的數據幀:
import pandas as pd
df = pd.DataFrame(data={'Volume': aapl['Volume'],
'Adjusted Close': aapl['Adjusted Close']})
字典的鍵將是數據的列名框架,並且相應的條目將成爲列。
看看DataFrame documentation,它可能會給你一些線索。
您需要提供更多信息,我認爲。數據的格式是什麼,你想要什麼格式。你在談論一個熊貓數據框? – Jezzamon
是的。熊貓數據框。我很抱歉,我是python的新手。 – jessica