From a6fbf426d63e98ff3a107eb98f20f4b6f6c49ebd Mon Sep 17 00:00:00 2001 From: Zhengbo Wang Date: Sun, 16 Jun 2024 19:28:02 +0800 Subject: [PATCH 1/4] DOC: Change `to_numic`'s `dtype_backend` default doc --- pandas/core/tools/numeric.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index 3d28a73df99d1..56a2197b4ce3a 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -64,6 +64,7 @@ def to_numeric( ---------- arg : scalar, list, tuple, 1-d array, or Series Argument to be converted. + errors : {'raise', 'coerce'}, default 'raise' - If 'raise', then invalid parsing will raise an exception. - If 'coerce', then invalid parsing will be set as NaN. @@ -88,7 +89,8 @@ def to_numeric( the dtype it is to be cast to, so if none of the dtypes checked satisfy that specification, no downcasting will be performed on the data. - dtype_backend : {'numpy_nullable', 'pyarrow'}, default 'numpy_nullable' + + dtype_backend : {'numpy_nullable', 'pyarrow'}, default not nullable numpy Back-end data type applied to the resultant :class:`DataFrame` (still experimental). Behaviour is as follows: From a76aba93f9987821fc3799d7ddb78b48a081c59e Mon Sep 17 00:00:00 2001 From: Zhengbo Wang Date: Wed, 19 Jun 2024 17:46:15 +0800 Subject: [PATCH 2/4] improve --- pandas/core/tools/numeric.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index 56a2197b4ce3a..5bc13c8cdb7a0 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -90,14 +90,15 @@ def to_numeric( checked satisfy that specification, no downcasting will be performed on the data. - dtype_backend : {'numpy_nullable', 'pyarrow'}, default not nullable numpy + dtype_backend : {'numpy_nullable', 'pyarrow'} Back-end data type applied to the resultant :class:`DataFrame` - (still experimental). Behaviour is as follows: + (still experimental). If not specified, the default behavior + is to not use nullable data types. If specified, the behavior + is as follows: - * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` - (default). + * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`. * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` - DataFrame. + DataFrame. .. versionadded:: 2.0 From e3dcfb362a45324d5255ee5d54d385819f0de2de Mon Sep 17 00:00:00 2001 From: Zhengbo Wang Date: Wed, 19 Jun 2024 17:49:19 +0800 Subject: [PATCH 3/4] improve --- 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 5bc13c8cdb7a0..730b4268aefc7 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -97,8 +97,7 @@ def to_numeric( is as follows: * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`. - * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` - DataFrame. + * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` DataFrame. .. versionadded:: 2.0 From 01841b2329c3e1e54e2527053a5b845de3f170c2 Mon Sep 17 00:00:00 2001 From: Zhengbo Wang Date: Wed, 19 Jun 2024 17:54:23 +0800 Subject: [PATCH 4/4] improve --- pandas/core/tools/numeric.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index 730b4268aefc7..3d406d3bfb115 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -96,8 +96,8 @@ def to_numeric( is to not use nullable data types. If specified, the behavior is as follows: - * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`. - * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` DataFrame. + * ``"numpy_nullable"``: returns with nullable-dtype-backed + * ``"pyarrow"``: returns with pyarrow-backed nullable :class:`ArrowDtype` .. versionadded:: 2.0