Skip to content

[backport 2.3.x] TST (string dtype): add explicit object vs str dtype to index fixture (#60116) #60136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jorisvandenbossche
Copy link
Member

Backport of #60116

Comment on lines 931 to 935
# For backwards compatibility, we let Index do its normal type
# inference, _except_ for if if infers from object to bool.
idx = Index(keys)
if idx.dtype == bool and keys.dtype == object:
if idx.dtype in [bool, "string"] and keys.dtype == object:
idx = idx.astype(object)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for 2.3.x in addition to the changes on main, because here the Index(..) is not yet updated to idx = Index(keys, dtype=keys.dtype) after the deprecation enforcement

@jorisvandenbossche jorisvandenbossche merged commit ce56f2e into pandas-dev:2.3.x Nov 4, 2024
57 of 62 checks passed
@jorisvandenbossche jorisvandenbossche deleted the backport-60116 branch November 4, 2024 08:52
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.

1 participant