ENH: Support datetime.date in Period Index #10798
Labels
datetime.date
stdlib datetime.date support
Datetime
Datetime data dtype
Enhancement
Indexing
Related to indexing on series/frames, not to indexes themselves
Period
Period data type
PeriodIndex
s should resolve whendatetime.date
is passed intoin
, but doesn't. Example below.Tracing this through, it looks like
parse_time_string
is expected to return a tuple inget_loc
(which is called by__contains__
): https://github.com/pydata/pandas/blob/master/pandas/tseries/period.py#L610But if passed something that isn't a string, just returns it back as a single item: https://github.com/pydata/pandas/blob/master/pandas/tseries/tools.py#L447
...so in this instance the lookup raises an exception and mistakenly propagates up that the value can't be found.
What's the best way forward here? Should the return type always be the same? Or do we add a check in
get_loc
to stop it callingparse_time_string
? Or broaden theexcept
here to be any exception: https://github.com/pydata/pandas/blob/master/pandas/tseries/period.py#L612My inclination is the first, but whether that will have some blast radius / what the standards are? The third seems like a reasonable cut through too.
The text was updated successfully, but these errors were encountered: