Skip to content

Conversation

jbrockmendel
Copy link
Member

cc @jorisvandenbossche

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good!

# GH#61916
warnings.warn(
"For backward compatibility, 'str' dtypes are included by "
"select_dtypes when object dtypes are specified. "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"select_dtypes when object dtypes are specified. "
"select_dtypes when 'object' dtype is specified. "

Comment on lines 2375 to 2380
To select string columns include ``str``:

.. ipython:: python
df.select_dtypes(include=["object"])
df.select_dtypes(include=[str])
Copy link
Member

Choose a reason for hiding this comment

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

I would maybe add a note that this changed in pandas 3.0 and that for pandas<3, include="object" was used. Maybe with a link to https://pandas.pydata.org/docs/user_guide/migration-3-strings.html#hardcoded-use-of-object-dtype

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, updated.

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Deprecate Functionality to remove in pandas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

String dtype: backwards compatibility of selecting "object" vs "str" columns in select_dtypes

3 participants