Skip to content

Commit

Permalink
Improve examples for Series.str.isnumeric shared docstring to include…
Browse files Browse the repository at this point in the history
… fraction, decimals, negatives and exponents
  • Loading branch information
akj2018 committed Feb 19, 2025
1 parent d4dff29 commit 42632c1
Showing 1 changed file with 18 additions and 1 deletion.
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. 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

0 comments on commit 42632c1

Please sign in to comment.