From af5ff18ef24f7f04ba73e67cef3f8e422961d714 Mon Sep 17 00:00:00 2001 From: Chilin Chiou Date: Sat, 19 Jul 2025 14:43:55 +0800 Subject: [PATCH 1/2] Doc: Clarify to_numeric behavior for numeric dtypes --- pandas/core/tools/numeric.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index c2ffe17adbac5..89d25ad2726f5 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -55,9 +55,11 @@ def to_numeric( """ Convert argument to a numeric type. - The default return dtype is `float64` or `int64` + If the input is already of a numeric dtype, the dtype will be preserved. + For non-numeric inputs, the default return dtype is `float64` or `int64` depending on the data supplied. Use the `downcast` parameter - to obtain other dtypes. + to obtain other dtypes. Numeric dtypes include all dtypes that have + the `_is_numeric` attribute set to `True`. Please note that precision loss may occur if really large numbers are passed in. Due to the internal limitations of `ndarray`, if From 494aaad6a89aea0ca426ff660ce09ec3af8a027d Mon Sep 17 00:00:00 2001 From: Chilin Chiou Date: Sat, 19 Jul 2025 23:41:54 +0800 Subject: [PATCH 2/2] remove internal attribute from doc --- pandas/core/tools/numeric.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index 89d25ad2726f5..54f4be1cb87b0 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -58,8 +58,7 @@ def to_numeric( If the input is already of a numeric dtype, the dtype will be preserved. For non-numeric inputs, the default return dtype is `float64` or `int64` depending on the data supplied. Use the `downcast` parameter - to obtain other dtypes. Numeric dtypes include all dtypes that have - the `_is_numeric` attribute set to `True`. + to obtain other dtypes. Please note that precision loss may occur if really large numbers are passed in. Due to the internal limitations of `ndarray`, if