“如何修复”';大熊猫.compat';没有属性';字符串类型'&引用;python3中的错误
我正在看教程,我试图用它来获取股票数据。您可以在请求数据时选择数据类型,我选择了“pandas”。当我运行内置函数时,我得到一个错误,读取“如何修复”';大熊猫.compat';没有属性';字符串类型'&引用;python3中的错误,python,python-3.x,pandas,Python,Python 3.x,Pandas,我正在看教程,我试图用它来获取股票数据。您可以在请求数据时选择数据类型,我选择了“pandas”。当我运行内置函数时,我得到一个错误,读取AttributeError:module'pandas.compat'没有属性'string\u types' 我正在使用python 3.7。我已经卸载并重新安装了iexfinance和pandas。我还创建了和IEX云帐户,并传入了一个机密密钥,如文档状态,但出现了相同的错误。本教程没有提到这些步骤中的任何一个,而且让人困惑的是,为什么他的作品和我的不一
AttributeError:module'pandas.compat'没有属性'string\u types'
我正在使用python 3.7。我已经卸载并重新安装了iexfinance和pandas。我还创建了和IEX云帐户,并传入了一个机密密钥,如文档状态,但出现了相同的错误。本教程没有提到这些步骤中的任何一个,而且让人困惑的是,为什么他的作品和我的不一样
我已尝试通过网站上的以下示例简化代码:即使在运行时:
from iexfinance.stocks import Stock
df = Stock("AAPL", output_format="pandas")
print(df.get_quote().head())
错误依然存在
预期产出为:
AAPL
avgTotalVolume 30578248
calculationPrice close
change -0.58
changePercent -0.00298
close 207.27
我收到的输出是:
Traceback (most recent call last):
File "app.py", line 18, in <module>
df = Stock("AAPL", output_format="pandas")
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/iexfinance/stocks/base.py", line 45, in __init__
self.symbols = list(map(lambda x: x.upper(), _handle_lists(symbols)))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/iexfinance/utils/__init__.py", line 43, in _handle_lists
if isinstance(l, (compat.string_types, int)):
AttributeError: module 'pandas.compat' has no attribute 'string_types'
回溯(最近一次呼叫最后一次):
文件“app.py”,第18行,在
df=库存(“AAPL”,输出格式=“熊猫”)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/iexfinance/stocks/base.py”,第45行,在__
self.symbols=list(映射(lambda x:x.upper(),_handle_list(symbols)))
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/iexfinance/utils/___init___.py”,第43行,在句柄列表中
如果isinstance(l,(compat.string_类型,int)):
AttributeError:模块“pandas.compat”没有属性“string\u types”
您可以尝试将pandas版本恢复到0.24.2,作为解决方法:
pip安装程序==0.24.2
在这一点上,我仍然不确定是熊猫身上有虫子还是别的什么
编辑:可能iexfinance正在Pandas中使用一些内部构件,Pandas已经经历了一次重大的更改,删除了python 2和所有兼容代码
这也已经在他们的问题追踪器上:
关于以下内容的方法:
pip安装=0.24.2
是正确的~试试这个。到2019年10月2日为止,只需将iexfinance更新到最新版本(0.4.3),问题就解决了
执行以下操作:
pip install iexfinance --upgrade
哇,这似乎奏效了。非常感谢你的建议!