【问题标题】:How to iterate over a columns of tickers of stocks and retrieve their financial data?如何遍历一列股票代码并检索其财务数据?
【发布时间】:2019-11-10 16:27:54
【问题描述】:

我的数据基本上是股票行情的列,例如:

MMM ABT ABBV    AC  AGRO    AUB AIR AAF BABA    AGN ... UBER    UTX VRTX    DG  V   VOW VOW3    VTBR

我想使用 for 循环来迭代每个代码并检索收盘价。现在我将其作为输出:

for ticker in data:    
    df = DataReader(ticker,'yahoo', start, end)['Adj Close']

它只输出一个股票代码的信息

我觉得我错过了什么

【问题讨论】:

  • for ticker in data.columns:

标签: python arrays pandas


【解决方案1】:

如果数据类型是字符串,请尝试使用拆分功能。

for ticker in data.split():
    df = DataReader(ticker,'yahoo', start, end)['Adj Close']

我希望这会有所帮助。

【讨论】:

  • 我尝试使用拆分功能。但是我收到一个错误:AttributeError: 'DataFrame' object has no attribute 'split'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-11
相关资源
最近更新 更多