BUG: Slicing on Datetimeindex fails #43223
Labels
Bug
Datetime
Datetime data dtype
Indexing
Related to indexing on series/frames, not to indexes themselves
Regression
Functionality that used to work in a prior pandas version
Milestone
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Error message:
Problem description
The execution of
df["2011-01-01": "2011-11-01"]
fails with the following exception:AssertionError: <class 'numpy.ndarray'>
. So the first problem is that the error message is not helping to solve the issue. Moreover, I observed that at least in Pandas 1.0.0 the code snippet is executed successfully. Additionally, if the index is sorted the error also does not occur:df.sort_index()["2011-01-01": "2011-11-01"]
Note a similar closed issue exists: #35509. With the current version the code snippet from that issue works. However, mine fails.
Expected Output
or helpful error message
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 5f648bf
python : 3.8.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252
pandas : 1.3.2
numpy : 1.18.4
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 53.1.0
Cython : None
pytest : 6.2.2
hypothesis : None
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.20.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.1
sqlalchemy : None
tables : None
tabulate : None
xarray : 0.18.2
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: