Skip to content

Commit 42632c1

Browse files
committed
Improve examples for Series.str.isnumeric shared docstring to include fraction, decimals, negatives and exponents
1 parent d4dff29 commit 42632c1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pandas/core/strings/accessor.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3549,12 +3549,29 @@ def casefold(self):
35493549
also includes other characters that can represent quantities such as
35503550
unicode fractions.
35513551
3552-
>>> s1 = pd.Series(['one', 'one1', '1', ''])
3552+
>>> s1 = pd.Series(['one', 'one1', '1', '', '³', '⅕'])
35533553
>>> s1.str.isnumeric()
35543554
0 False
35553555
1 False
35563556
2 True
35573557
3 False
3558+
4 True
3559+
5 True
3560+
dtype: bool
3561+
3562+
For a string to be considered numeric, all its characters must have a Unicode
3563+
numeric property. As a consequence, the following cases are **not** recognized
3564+
as numeric:
3565+
3566+
- **Decimal numbers** (e.g., "1.1"): due to period ``"."``
3567+
- **Negative numbers** (e.g., "-5"): due to minus sign ``"-"``
3568+
- **Scientific notation** (e.g., "1e3"): due to characters like ``"e"``
3569+
3570+
>>> s2 = pd.Series(["1.1", "-5", "1e3"])
3571+
>>> s2.str.isnumeric()
3572+
0 False
3573+
1 False
3574+
2 False
35583575
dtype: bool
35593576
"""
35603577
_shared_docs["isalnum"] = """

0 commit comments

Comments
 (0)