我正在使用yahoo_quote_download库从yahoo finance获取一些数据,作为pandasDataFrame
或csv
文件,然后我可以将其制作成DataFrame
。然而,当我使用yqd.load_yahoo_quote(ticker, start_date, end_date)
时,它会返回如下列表:
['Date,Open,High,Low,Close,Adj Close,Volume',
'2015-01-12,159.000000,159.250000,155.759995,156.440002,135.236679,4182800',
'2015-01-13,157.259995,159.970001,155.679993,156.809998,135.556564,4377500']
不过,我需要的是一个pandasDataFrame
或CSV
文件。如有任何帮助,我们将不胜感激。
试试这个:
mylist = ['Date,Open,High,Low,Close,Adj Close,Volume',
'2015-01-12,159.000000,159.250000,155.759995,156.440002,135.236679,4182800',
'2015-01-13,157.259995,159.970001,155.679993,156.809998,135.556564,4377500']
import pandas as pd
df = pd.DataFrame([i.split(',') for i in mylist[1:]], columns=list(mylist[0].split(',')))
df