-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
KeyError in datetime pandas when accessing with datetime.date #38037
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
Comments
Can you post a copy/paste-able example https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports Best guess is that it isn't Big Sur, but that you recently updated to a newer version of pandas. There have been a few issues involving |
Exactly, I have downgraded it to 1.0.5 and everything works know ! Thank you mate ! |
Wouldn't Simpler reproducer: >>> _ = pd.Series([0], index=[pd.Timestamp('2020-01-01')])[pd.Timestamp('2020-01-01')] # works
>>> _ = pd.Series([0], index=[pd.Timestamp('2020-01-01')])[pd.Timestamp('2020-01-01').date()] # error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/marco/tmp/venv/lib/python3.8/site-packages/pandas/core/series.py", line 851, in __getitem__
return self._get_value(key)
File "/home/marco/tmp/venv/lib/python3.8/site-packages/pandas/core/series.py", line 959, in _get_value
loc = self.index.get_loc(label)
File "/home/marco/tmp/venv/lib/python3.8/site-packages/pandas/core/indexes/datetimes.py", line 683, in get_loc
raise KeyError(key)
KeyError: datetime.date(2020, 1, 1) As was suggested above:
Anyway, from
|
This comment was marked as off-topic.
This comment was marked as off-topic.
@KylePoe you're welcome to make a PR |
datetime.datetime(2016,1,1) worked for me, while I was trying datetime.date(2016,1,1). My pandas version is 1.4.1. As soon I updated my pandas library this error started showing up. New versions of pandas accept datetime.datetime rather than datetime.date! |
I've just upgrade Big Sur 11.0.1 and I'm facing some issue while trying to execute a notebook. Weird because it worked on Catalina. Could anyone help ?
And here the errors:
The text was updated successfully, but these errors were encountered: