Pandas 列返回非类型,尽管所有行都有值
Pandas column returning nonetype despite having values for all rows
我已经使用下面的代码和输出下载了一个数据集:
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
数据 table 输出正常,但是当我尝试用以下内容隔离列时,我收到此错误:
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
我已经使用下面的代码和输出下载了一个数据集:
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
数据 table 输出正常,但是当我尝试用以下内容隔离列时,我收到此错误:
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