Skip to content

Conversation

@SoulSniper1212
Copy link

@SoulSniper1212 SoulSniper1212 commented Nov 11, 2025

Overview

This PR fixes an issue where using scalar row + slice columns indexing (e.g. df[scalar_row, slice_columns]) would not preserve column dtypes properly. The fix implements a special case for this indexing pattern to first extract the column slice, preserving dtypes, then extract the specific row.

Checklist

  • Code changes implemented
  • Tests added to verify the fix
  • Documentation updated (if applicable)

Proof

The fix addresses issue #63071 by handling the scalar row + slice columns case specifically in _LocationIndexer._getitem_lowerdim. The solution first gets the column slice to create a sub-DataFrame with preserved column dtypes, then extracts the required row from this sub-DataFrame. This ensures that the resulting Series maintains the original column dtypes as expected.

Closes #63071

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: DataFrame.loc[] returns object type instead of float

1 participant