我已使用下面的代码下载了数据集并输出如下:
def aroon(symbol):
aroon = TechIndicators(key='',output_format='pandas')
data, meta_data = aroon.get_aroon(symbol = symbol, interval = 'daily')
modifiedfp = pandas.DataFrame(data)
modifiedfp = modifiedfp.reset_index()
modifiedfp
print modifiedfp
x = aroon('msft')
和输出:
date Aroon Down Aroon Up
0 2020-04-07 45.0 100.0
1 2020-04-08 40.0 95.0
2 2020-04-09 35.0 90.0
3 2020-04-13 30.0 85.0
4 2020-04-14 25.0 100.0
5 2020-04-15 20.0 95.0
6 2020-04-16 15.0 100.0
7 2020-04-17 10.0 100.0
8 2020-04-20 5.0 95.0
9 2020-04-21 0.0 90.0
Process finished with exit code 0
数据表很好,但是当我尝试使用以下内容隔离列时,出现此错误:
y = x['Aroon Down']
Traceback (most recent call last):
File "/Users/davidgaballa/Library/Preferences/PyCharmCE2018.3/scratches/scratch_7.py",
line 37, in <module>
y = x['Aroon Down']
TypeError: 'NoneType' object has no attribute '__getitem__'
最终,我想将这些列之一附加到另一个数据帧,但是当我尝试并一直在努力找出问题的源头时,我遇到了同样的问题。在我看来,所有行都有一个值,所以我不确定为什么会遇到此问题。谢谢您的帮助。
您实际上并没有在aroon
函数中返回任何内容。修改为:
def aroon(symbol):
aroon = TechIndicators(key='',output_format='pandas')
data, meta_data = aroon.get_aroon(symbol = symbol, interval = 'daily')
modifiedfp = pandas.DataFrame(data)
modifiedfp = modifiedfp.reset_index()
print modifiedfp
return modifiedfp