You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above code creates a datetimeindex of 15 minute intervals and then removes all rows deemed as weekend times (although weekends are not defined by midnight and use a specific time of day) This works with pandas version 19 but when I looked to upgrade a numpy error is returned. This occurs on both Python 2.7 and Python 3.6
Errors:
Pandas 0.20.3
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 296, in getitem
result = getitem(key)
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
Pandas 0.21.1
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 279, in getitem
key = lib.maybe_booleans_to_slice(key.view(np.uint8))
File "%PY_HOME%\lib\site-packages\numpy\core_internal.py", line 365, in _view_is_safe
raise TypeError("Cannot change data-type for object array.")
TypeError: Cannot change data-type for object array.
Pandas 0.22.0
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 279, in getitem
key = lib.maybe_booleans_to_slice(key.view(np.uint8))
File "%PY_HOME%\lib\site-packages\numpy\core_internal.py", line 365, in _view_is_safe
raise TypeError("Cannot change data-type for object array.")
TypeError: Cannot change data-type for object array.
Pandas 0.23.4
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 411, in getitem
key = lib.maybe_booleans_to_slice(key.view(np.uint8))
File "%PY_HOME%\lib\site-packages\numpy\core_internal.py", line 365, in _view_is_safe
raise TypeError("Cannot change data-type for object array.")
TypeError: Cannot change data-type for object array.
The text was updated successfully, but these errors were encountered:
In [27]: pd.__version__
Out[27]: '0.24.0.dev0+523.gbf6763458'
In [28]: dti = pd.DatetimeIndex(['2012-01-01'])
# Interestingly works for True
In [29]: dti[pd.Index([True])]
Out[29]: DatetimeIndex(['2012-01-01'], dtype='datetime64[ns]', freq=None)
In [30]: dti[pd.Index([False])]
TypeError: Cannot change data-type for object array.
Investigations and PR's welcome!
mroeschke
changed the title
Regression: DateTimeIndex Map Function Returns numpy Error
BUG: DatetimeIndex.__getitem__ with boolean mask with False raises TypeError
Aug 29, 2018
mroeschke
changed the title
BUG: DatetimeIndex.__getitem__ with boolean mask with False raises TypeError
BUG: DatetimeIndex.__getitem__ with boolean Index mask with False raises TypeError
Aug 29, 2018
The above code creates a datetimeindex of 15 minute intervals and then removes all rows deemed as weekend times (although weekends are not defined by midnight and use a specific time of day) This works with pandas version 19 but when I looked to upgrade a numpy error is returned. This occurs on both Python 2.7 and Python 3.6
Errors:
Pandas 0.20.3
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 296, in getitem
result = getitem(key)
IndexError: only integers, slices (
:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indicesPandas 0.21.1
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 279, in getitem
key = lib.maybe_booleans_to_slice(key.view(np.uint8))
File "%PY_HOME%\lib\site-packages\numpy\core_internal.py", line 365, in _view_is_safe
raise TypeError("Cannot change data-type for object array.")
TypeError: Cannot change data-type for object array.
Pandas 0.22.0
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 279, in getitem
key = lib.maybe_booleans_to_slice(key.view(np.uint8))
File "%PY_HOME%\lib\site-packages\numpy\core_internal.py", line 365, in _view_is_safe
raise TypeError("Cannot change data-type for object array.")
TypeError: Cannot change data-type for object array.
Pandas 0.23.4
Traceback (most recent call last):
File "PandasTest.py", line 41, in
rng = rng[rng.map(removeWeekends)]
File "%PY_HOME%\lib\site-packages\pandas\core\indexes\datetimelike.py", line 411, in getitem
key = lib.maybe_booleans_to_slice(key.view(np.uint8))
File "%PY_HOME%\lib\site-packages\numpy\core_internal.py", line 365, in _view_is_safe
raise TypeError("Cannot change data-type for object array.")
TypeError: Cannot change data-type for object array.
The text was updated successfully, but these errors were encountered: