我有一個問題,使用當前版本的熊貓向後填充numpy日期向量。相同的代碼適用於早期版本。下面演示了我的問題:熊貓DataFrame錯誤「元組索引超出範圍」
舊版本(0.7.3)的作品
C:\WINDOWS\system32>pip show pandas
Name: pandas
Version: 0.7.3
Summary: Powerful data structures for data analysis and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: [email protected]
License: BSD
Location: c:\program files\python\python27\lib\site-packages
Requires: python-dateutil, numpy
C:\WINDOWS\system32>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> d=np.array([None, None, None, None, dt.now(), None])
>>> b = DataFrame(d)
>>> b.fillna(method='backfill')
0
0 2017-04-02 12:21:18.175000
1 2017-04-02 12:21:18.175000
2 2017-04-02 12:21:18.175000
3 2017-04-02 12:21:18.175000
4 2017-04-02 12:21:18.175000
5 None
>>>
目前vesion(0.19.2)不工作:
C:\WINDOWS\system32>pip show pandas
Name: pandas
Version: 0.19.2
Summary: Powerful data structures for data analysis, time series,and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: [email protected]
License: BSD
Location: c:\program files\python\python27\lib\site-packages
Requires: pytz, python-dateutil, numpy
C:\WINDOWS\system32>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime as dt
>>> import numpy as np
>>> from pandas import DataFrame
>>> d=np.array([None, None, None, None, dt.now(), None])
>>> b = DataFrame(d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\frame.py", line 297, in __init__
copy=copy)
File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\frame.py", line 474, in _init_ndarray
return create_block_manager_from_blocks([values], [columns, index])
File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\internals.py", line 4256, in create_block_manager_from_blocks
construction_error(tot_items, blocks[0].shape[1:], axes, e)
File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\internals.py", line 4230, in construction_error
if block_shape[0] == 0:
IndexError: tuple index out of range
>>>
我在做什麼像我認爲的那樣,錯誤還是它是熊貓中的一個錯誤?如果它有一個錯誤,我該如何報告?
編輯:這是作爲提起錯誤報告與大熊貓,將被固定在一個次RELASE(0.19.3)
感謝您的回答。你能告訴我在哪裏報告嗎?你還可以解釋你的測試中發生了什麼。爲什麼一個工作,另一個不工作? –
@RichardB:熊貓問題追蹤器在這裏:https://github.com/pandas-dev/pandas/issues –