1
我正在嘗試使用日期和股票行情組合查找一個熊貓(版本0.14.1)數據框中的一行,並且正在接收一個奇怪的錯誤。熊貓數據框 - 查找錯誤
我的熊貓數據框,看起來像這樣:
AAPL IBM GOOG XOM Date
2011-01-10 16:00:00 340.99 143.41 614.21 72.02 2011-01-10
2011-01-11 16:00:00 340.18 143.06 616.01 72.56 2011-01-11
2011-01-12 16:00:00 342.95 144.82 616.87 73.41 2011-01-12
2011-01-13 16:00:00 344.20 144.55 616.69 73.54 2011-01-13
2011-01-14 16:00:00 346.99 145.70 624.18 74.62 2011-01-14
2011-01-18 16:00:00 339.19 146.33 639.63 75.45 2011-01-18
2011-01-19 16:00:00 337.39 151.22 631.75 75.00 2011-01-19
當我嘗試使用日期/串組合,收到以下錯誤進行查找:
>>> df_data.lookup(date,ticker)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2820, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-2-31ab981e2184>", line 1, in <module>
df_data.lookup(date,ticker)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 2207, in lookup
n = len(row_labels)
TypeError: object of type 'datetime.datetime' has no len()
從我所看到的熊貓文檔中,這應該工作,我的日期變量是一個普通的日期時間
>>> date
Out[5]: datetime.datetime(2011, 1, 10, 16, 0)
我在做什麼明顯不正確嗎?