BUG: Change output returned by _LocIndexer._convert_to_indexer to return key with greater resolution value #57646
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolution info:
Resolution.RESO_SEC - 3 for seconds
Resolution.RESO_MIN - 4 for minute
Observation:
With the previous code, when the current entry (resolution: 4, entry: '2024-02-24 10:08') has a greater resolution value than the smallest amongst previous entries (in this case resolution: 3, entry: '2024-02-24 10:2:30'), it is shown that the key is said to exist within the list of keys within the Series even though it shouldn't. This does not happen when a smaller or equal resolution value entry is inserted into the Series.
Thought process:
With the previous code, if the current entry's resolution value is greater than the smallest resolution value amongst the previous entries, the _LocIndexer._convert_to_indexer method will only return an empty list (output of the method labels.get_loc(key)), which might be causing entries with larger resolution values not being inserted into the Series correctly.
Potential solution:
I have changed the method _LocIndexer._convert_to_indexer to return the key ('2024-02-24 10:08') instead of an empty list when the resolution value is greater than the smallest resolution value.
doc/source/whatsnew/v2.2.1.rst
file if fixing a bug or adding a new feature.