From a9b75cf74c8b2edbdc5153f584f5416e3b17e187 Mon Sep 17 00:00:00 2001 From: boringow <62092582+boringow@users.noreply.github.com> Date: Fri, 27 Nov 2020 18:43:58 +0100 Subject: [PATCH] Update datetimes.py I was working today with datetime index, you have the reso (resolutions) defined from year to nanosecond, but then you had the lines 560-570 repeating 'minute' and 'second', and working with millisecond or nanosecond raises a KeyIndex error. --- pandas/core/indexes/datetimes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index f6eeb121b1ac0..53d573e7eed71 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -565,10 +565,11 @@ def _parsed_string_to_bounds(self, reso: Resolution, parsed: datetime): "hour", "minute", "second", - "minute", - "second", + "millisecond", "microsecond", + "nanosecond" } + if reso.attrname not in valid_resos: raise KeyError