Skip to content

DOC: fix doctests for pandas/core/strings/accessor.py for new string dtype #61908

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arthurlw
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Part of #61886

@arthurlw
Copy link
Member Author

arthurlw commented Jul 19, 2025

cc @jorisvandenbossche

I noticed that some of the docstrings highlight differences between returning NaN and False for boolean operations (e.g., here), which are now outdated. These should be updated, though it might be better to open a separate issue for that.

Other files may have similar cases, though I haven't done a full check yet.

@arthurlw arthurlw added the Docs label Jul 19, 2025
@jorisvandenbossche
Copy link
Member

I noticed that some of the docstrings highlight differences between returning NaN and False for boolean operations (e.g., here), which are now outdated. These should be updated, though it might be better to open a separate issue for that.

Good catch. That was an intentional change, see #54805 / #59616, so it is fine to update the docstrings here while updating them to use the string dtype.

Comment on lines 1282 to +1284
>>> ind = pd.Index(["Mouse", "dog", "house and parrot", "23.0", np.nan])
>>> ind.str.contains("23", regex=False)
Index([False, False, False, True, nan], dtype='object')
array([False, False, False, True, False])
Copy link
Member

Choose a reason for hiding this comment

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

The fact that it changes here from Index to array does not seem to be intentional, though. Will look into that.

4 NaN
dtype: object
4 False
dtype: bool

Specifying `na` to be `False` instead of `NaN` replaces NaN values
Copy link
Member

Choose a reason for hiding this comment

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

I realized that this example is now also a bit outdated (we could still show it when starting with object dtype, or show it with filling with another value), but that is also fine to keep for another PR

@@ -3640,7 +3640,7 @@ def casefold(self):
>>> s3 = pd.Series(['23', '³', '⅕', ''])
>>> s3.str.isdigit()
0 True
1 True
1 False
Copy link
Member

Choose a reason for hiding this comment

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

This is a behaviour change we should actually fix, see #61466

@jorisvandenbossche
Copy link
Member

@arthurlw thanks for the PR!

@jorisvandenbossche jorisvandenbossche added this to the 3.0 milestone Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants