type(a) <class 'pandas.core.frame.DataFrame'>
当我尝试获取'2016-08-10 09:00:00'
的下一个索引时,我得到了这个结果。我只是不知道为什么。我想我已经定义了方法&#39;回填&#39;因此结果应该是唯一的,并且数据框确实包含'2016-08-10 09:00:01'
和'2016-08-10 09:00:02'
等索引。此网站可能会有所帮助。
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Index.get_loc.html
a.index.get_loc('2016-08-10 09:00:00','backfill')
Traceback (most recent call last): File "<pyshell#49>", line 1, in
<module>
a.index.get_loc('2016-08-10 09:00:00','backfill') File "C:\Python27\lib\site-packages\pandas\tseries\index.py", line 1431, in
get_loc
return Index.get_loc(self, key, method, tolerance) File "C:\Python27\lib\site-packages\pandas\indexes\base.py", line 1949, in
get_loc
indexer = self.get_indexer([key], method=method, tolerance=tolerance) File
"C:\Python27\lib\site-packages\pandas\indexes\base.py", line 2079, in
get_indexer
tolerance=tolerance) File "C:\Python27\lib\site-packages\pandas\indexes\base.py", line 2082, in
get_indexer
raise InvalidIndexError('Reindexing only valid with uniquely' InvalidIndexError: Reindexing only valid with uniquely valued Index
objects