-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: indexing DatetimeIndex with date object #35830
Comments
The issue is unrelated to Excel, just in how to index with a DatetimeIndex. Minimal reproducer:
In general, you should use datetime or Timestamp objects when indexing on a DatetimeIndex, as in general date objects are not supported (we are not as consistent about this as we'd like to be) |
since this was working in 1.0.5 will mark as regression
|
moved off 1.1.2 milestone (scheduled for this week) as no PRs to fix in the pipeline |
first bad commit: [9b0ef5d] refactor DTI.get_loc (#31023) https://github.com/simonjayhawkins/pandas/runs/1082023137?check_suite_focus=true see also #35466 |
moved off 1.1.3 milestone (overdue) as no PRs to fix in the pipeline |
Any chance of this getting fixed? |
#35478 is perhaps addressing it, though it's not clear that the current behavior is incorrect. IMO, we This is complicated a bit by partial string indexing, but I still think there's reason to be stricter here, given the ambiguity of: In [6]: s = pd.Series([1, 2], index=pd.DatetimeIndex(['2000-01-01 00:00:00', '2000-01-01 00:00:01']))
In [7]: s[datetime.date(2000, 1, 1)] Does that behave like a datetime at midnight, selecting just the first row? Or is it similar to partial string indexing, selecting all rows on that day regardless of the time? |
My thoughts:
By the way, note that
|
This is incorrect as is, should be deprecated. |
moved off 1.1.4 milestone (scheduled for release tomorrow) as no PRs to fix in the pipeline |
Hello, Indexing DateTime index by date as above has worked forever and we have hundreds of loc that depend on this behaviour. Would you be open to a PR that promotes date to datetime in get_loc?
|
@TomAugspurger that's a fair point but the problem here is that this behaviour has been around for ever and is likely relied upon by many people using daily data, a very common use-case. I don't unintentionally breaking this without warning is in the spirit of the contribution guidelines. |
IIRC we were inconsistent earlier. @jbrockmendel would know best. |
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
down load this file
bug.xlsx
or create an excel file with the follwoing:
then run the following code
Problem description
I have this error on 1.1.0 and 1.1.1:
Expected Output
no error, with pandas 1.0.5, it finds the element.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f2ca0a2
python : 3.7.3.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.1.1
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
numba : Non
The text was updated successfully, but these errors were encountered: