def load_tickers(ticker):
fname = ( '%s.csv' % ticker.lower())
data = pd.read_csv( fname, header = None, parse_dates = ['Date'],
names =['Date','Open','High','Low','c','Adj Close','Volume'])
data = data.set_index('Date')
x = pd.DataFrame(ticker: data.c)
print(x)
load_tickers('AAPL')
我尝试运行代码,但由于某种原因,它引发了SyntaxError:
我该如何解决?
答案 0 :(得分:0)
好像您想传递字典并忘记了花括号。试试这个:
x = pd.DataFrame({ticker: data.c})