-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
DEPR: back-compat shim for select_dtypes #62718
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
DEPR: back-compat shim for select_dtypes #62718
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
pandas/core/frame.py
Outdated
# GH#61916 | ||
warnings.warn( | ||
"For backward compatibility, 'str' dtypes are included by " | ||
"select_dtypes when object dtypes are specified. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"select_dtypes when object dtypes are specified. " | |
"select_dtypes when 'object' dtype is specified. " |
To select string columns include ``str``: | ||
|
||
.. ipython:: python | ||
df.select_dtypes(include=["object"]) | ||
df.select_dtypes(include=[str]) | ||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, updated.
.. note:: | ||
|
||
This is a change in pandas 3.0. Previously strings were stored in ``object`` dtype columns, so would be selected with ``include=[object]``. See https://pandas.pydata.org/docs/user_guide/migration-3-strings.html#hardcoded-use-of-object-dtype. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a change in pandas 3.0. Previously strings were stored in ``object`` dtype columns, so would be selected with ``include=[object]``. See https://pandas.pydata.org/docs/user_guide/migration-3-strings.html#hardcoded-use-of-object-dtype. | |
This is a change in pandas 3.0. Previously strings were stored in ``object`` dtype columns, so would be selected with ``include=[object]``. See :ref:`string_migration.object`. |
Best to use internal references for something like this (but will do this in a follow-up PR expanding that section a bit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration guide actually already had the content, but so just updating the reference, and also added a link to the depr warning -> #62759
@jbrockmendel thanks! |
select_dtypes
#61916 (Replace xxxx with the GitHub issue number)doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.cc @jorisvandenbossche