Skip to content

DOC: Improve examples in Series.str.isnumeric shared docstring to include decimal, fraction, negatives and exponents (#60750) #60960

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
merged 3 commits into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3549,12 +3549,29 @@ def casefold(self):
also includes other characters that can represent quantities such as
unicode fractions.

>>> s1 = pd.Series(['one', 'one1', '1', ''])
>>> s1 = pd.Series(['one', 'one1', '1', '', '³', '⅕'])
>>> s1.str.isnumeric()
0 False
1 False
2 True
3 False
4 True
5 True
dtype: bool

For a string to be considered numeric, all its characters must have a Unicode
numeric property matching :py:meth:`str.is_numeric`. As a consequence,
the following cases are **not** recognized as numeric:

- **Decimal numbers** (e.g., "1.1"): due to period ``"."``
- **Negative numbers** (e.g., "-5"): due to minus sign ``"-"``
- **Scientific notation** (e.g., "1e3"): due to characters like ``"e"``

>>> s2 = pd.Series(["1.1", "-5", "1e3"])
>>> s2.str.isnumeric()
0 False
1 False
2 False
dtype: bool
"""
_shared_docs["isalnum"] = """
Expand Down