diff --git a/doc/source/whatsnew/v2.2.1.rst b/doc/source/whatsnew/v2.2.1.rst index 310dd921e44f6..ce2c54668ed61 100644 --- a/doc/source/whatsnew/v2.2.1.rst +++ b/doc/source/whatsnew/v2.2.1.rst @@ -62,6 +62,7 @@ Bug fixes - Fixed bug in :func:`pandas.api.interchange.from_dataframe` which wasn't converting columns names to strings (:issue:`55069`) - Fixed bug in :meth:`DataFrame.__getitem__` for empty :class:`DataFrame` with Copy-on-Write enabled (:issue:`57130`) - Fixed bug in :meth:`PeriodIndex.asfreq` which was silently converting frequencies which are not supported as period frequencies instead of raising an error (:issue:`56945`) +- Fixed bug in :meth:`_LocIndexer._convert_to_indexer` which doesn't properly insert timestamps into Series (:issue:`57596`) .. --------------------------------------------------------------------------- .. _whatsnew_221.other: diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index c7a938dbc4449..ef06ebdbb96a6 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1490,7 +1490,10 @@ def _convert_to_indexer(self, key, axis: AxisInt): # if we are a label return me try: - return labels.get_loc(key) + label = labels.get_loc(key) + if label: + return label + return {"key": key} except LookupError: if isinstance(key, tuple) and isinstance(labels, MultiIndex): if len(key) == labels.nlevels: