Skip to content

Commit 454b9d4

Browse files
authored
DOC: Improve examples in Series.str.isnumeric shared docstring to include decimal, fraction, negatives and exponents (#60750) (#60960)
* Improve examples for Series.str.isnumeric shared docstring to include fraction, decimals, negatives and exponents * Fixed trailing white space issue using pre-commit hook * DOC: Explicity mentioned type of Unicode numeric property in shared docstring for Series.str.isnumeric
1 parent ddcec67 commit 454b9d4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: pandas/core/strings/accessor.py

+18-1
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 matching :py:meth:`str.is_numeric`. As a consequence,
3564+
the following cases are **not** recognized 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)