From 58ce231877f5b2803bbe3eb539c996c31e4e46ae Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Fri, 13 Jan 2023 21:39:01 +0100 Subject: [PATCH 1/3] DOC: list supported float dtypes I --- doc/source/user_guide/basics.rst | 63 ++++++++++++++++++-------------- pandas/core/tools/numeric.py | 2 +- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/doc/source/user_guide/basics.rst b/doc/source/user_guide/basics.rst index f30c66d75b525..5b99fa5f03984 100644 --- a/doc/source/user_guide/basics.rst +++ b/doc/source/user_guide/basics.rst @@ -2050,33 +2050,42 @@ The following table lists all of pandas extension types. For methods requiring ` arguments, strings can be specified as indicated. See the respective documentation sections for more on each type. -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| Kind of Data | Data Type | Scalar | Array | String Aliases | -+=================================================+===============+===========+========+===========+===============================+========================================+ -| :ref:`tz-aware datetime ` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, ]'`` | -| | | | | | -+-------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Categorical ` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`period (time spans) ` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[]'``, | -| | | | ``'Period[]'`` | | -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`sparse ` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | -| | | | | ``'Sparse[float]'`` | -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`intervals ` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | -| | | | | ``'Interval[]'``, | -| | | | | ``'Interval[datetime64[ns, ]]'``, | -| | | | | ``'Interval[timedelta64[]]'`` | -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`nullable integer ` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | -| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,| -| | | | | ``'UInt32'``, ``'UInt64'`` | -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Strings ` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Boolean (with NA) ` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | -+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| Kind of Data | Data Type | Scalar | Array | String Aliases | ++=============================================================================================+===============+===========+========+===========+===============================+========================================+ +| :ref:`tz-aware datetime ` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, ]'`` | +| | | | | | ++---------------------------------------------------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Categorical ` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`period (time spans) ` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[]'``, | +| | | | ``'Period[]'`` | | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`sparse ` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | +| | | | | ``'Sparse[float]'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`intervals ` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | +| | | | | ``'Interval[]'``, | +| | | | | ``'Interval[datetime64[ns, ]]'``, | +| | | | | ``'Interval[timedelta64[]]'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`nullable integer ` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | +| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,| +| | | | | ``'UInt32'``, ``'UInt64'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| `NumPy integer `_ | :class:`numpy.integer` | :class:`int` | :class:`arrays.IntegerArray` | ``'int8'``, ``'int16'``, ``'int32'``, | +| | | | | ``'int64'``, ``'uint8'``, ``'uint16'``,| +| | | | | ``'uint32'``, ``'uint64'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| ``nullable float`` | :class:`Float64Dtype`, ...| (none) | :class:`arrays.FloatingArray` | ``'Float32'``, ``'Float64'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| `NumPy float `_ | :class:`numpy.floating` | :class:`float` | :class:`arrays.FloatingArray` | ``'float16'``, ``'float32'``, | +| | | | | ``'float64'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Strings ` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Boolean (with NA) ` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | ++---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ pandas has two ways to store strings. diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index a8ae8c47b0d19..ba700ba1e5f81 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -70,7 +70,7 @@ def to_numeric( - 'integer' or 'signed': smallest signed int dtype (min.: np.int8) - 'unsigned': smallest unsigned int dtype (min.: np.uint8) - - 'float': smallest float dtype (min.: np.float32) + - 'float': float dtype (min.: np.float32), float16 is not supported. As this behaviour is separate from the core conversion to numeric values, any errors raised during the downcasting From 7f6f54492da067d4668e64a5dd745e8aad46e0ab Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Thu, 26 Jan 2023 23:27:09 +0100 Subject: [PATCH 2/3] DOC: list supported float dtypes II --- doc/source/user_guide/basics.rst | 65 ++++++++++++++------------------ 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/doc/source/user_guide/basics.rst b/doc/source/user_guide/basics.rst index 5b99fa5f03984..51bbf841e6997 100644 --- a/doc/source/user_guide/basics.rst +++ b/doc/source/user_guide/basics.rst @@ -2050,42 +2050,35 @@ The following table lists all of pandas extension types. For methods requiring ` arguments, strings can be specified as indicated. See the respective documentation sections for more on each type. -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| Kind of Data | Data Type | Scalar | Array | String Aliases | -+=============================================================================================+===============+===========+========+===========+===============================+========================================+ -| :ref:`tz-aware datetime ` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, ]'`` | -| | | | | | -+---------------------------------------------------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Categorical ` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`period (time spans) ` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[]'``, | -| | | | ``'Period[]'`` | | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`sparse ` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | -| | | | | ``'Sparse[float]'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`intervals ` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | -| | | | | ``'Interval[]'``, | -| | | | | ``'Interval[datetime64[ns, ]]'``, | -| | | | | ``'Interval[timedelta64[]]'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`nullable integer ` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | -| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,| -| | | | | ``'UInt32'``, ``'UInt64'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| `NumPy integer `_ | :class:`numpy.integer` | :class:`int` | :class:`arrays.IntegerArray` | ``'int8'``, ``'int16'``, ``'int32'``, | -| | | | | ``'int64'``, ``'uint8'``, ``'uint16'``,| -| | | | | ``'uint32'``, ``'uint64'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| ``nullable float`` | :class:`Float64Dtype`, ...| (none) | :class:`arrays.FloatingArray` | ``'Float32'``, ``'Float64'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| `NumPy float `_ | :class:`numpy.floating` | :class:`float` | :class:`arrays.FloatingArray` | ``'float16'``, ``'float32'``, | -| | | | | ``'float64'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Strings ` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Boolean (with NA) ` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | -+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| Kind of Data | Data Type | Scalar | Array | String Aliases | ++==================================================+===============+===========+========+===========+===============================+========================================+ +| :ref:`tz-aware datetime ` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, ]'`` | +| | | | | | ++--------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Categorical ` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`period (time spans) ` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[]'``, | +| | | | ``'Period[]'`` | | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`sparse ` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | +| | | | | ``'Sparse[float]'`` | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`intervals ` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | +| | | | | ``'Interval[]'``, | +| | | | | ``'Interval[datetime64[ns, ]]'``, | +| | | | | ``'Interval[timedelta64[]]'`` | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`nullable integer ` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | +| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,| +| | | | | ``'UInt32'``, ``'UInt64'`` | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| ``nullable float`` | :class:`Float64Dtype`, ...| (none) | :class:`arrays.FloatingArray` | ``'Float32'``, ``'Float64'`` | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Strings ` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Boolean (with NA) ` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | ++--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ pandas has two ways to store strings. From 71df72e8fc4d29f6893748862b3c56d49686d3e3 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Sat, 28 Jan 2023 09:02:12 +0100 Subject: [PATCH 3/3] DOC: list supported float dtypes III --- doc/source/user_guide/basics.rst | 58 ++++++++++++++++---------------- pandas/core/tools/numeric.py | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/doc/source/user_guide/basics.rst b/doc/source/user_guide/basics.rst index 51bbf841e6997..8ca81acd6a704 100644 --- a/doc/source/user_guide/basics.rst +++ b/doc/source/user_guide/basics.rst @@ -2050,35 +2050,35 @@ The following table lists all of pandas extension types. For methods requiring ` arguments, strings can be specified as indicated. See the respective documentation sections for more on each type. -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| Kind of Data | Data Type | Scalar | Array | String Aliases | -+==================================================+===============+===========+========+===========+===============================+========================================+ -| :ref:`tz-aware datetime ` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, ]'`` | -| | | | | | -+--------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Categorical ` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`period (time spans) ` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[]'``, | -| | | | ``'Period[]'`` | | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`sparse ` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | -| | | | | ``'Sparse[float]'`` | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`intervals ` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | -| | | | | ``'Interval[]'``, | -| | | | | ``'Interval[datetime64[ns, ]]'``, | -| | | | | ``'Interval[timedelta64[]]'`` | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`nullable integer ` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | -| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,| -| | | | | ``'UInt32'``, ``'UInt64'`` | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| ``nullable float`` | :class:`Float64Dtype`, ...| (none) | :class:`arrays.FloatingArray` | ``'Float32'``, ``'Float64'`` | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Strings ` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ -| :ref:`Boolean (with NA) ` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | -+--------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| Kind of Data | Data Type | Scalar | Array | String Aliases | ++=================================================+===============+===========+========+===========+===============================+========================================+ +| :ref:`tz-aware datetime ` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, ]'`` | +| | | | | | ++-------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Categorical ` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`period (time spans) ` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[]'``, | +| | | | ``'Period[]'`` | | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`sparse ` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | +| | | | | ``'Sparse[float]'`` | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`intervals ` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | +| | | | | ``'Interval[]'``, | +| | | | | ``'Interval[datetime64[ns, ]]'``, | +| | | | | ``'Interval[timedelta64[]]'`` | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`nullable integer ` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | +| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,| +| | | | | ``'UInt32'``, ``'UInt64'`` | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| ``nullable float`` | :class:`Float64Dtype`, ...| (none) | :class:`arrays.FloatingArray` | ``'Float32'``, ``'Float64'`` | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Strings ` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ +| :ref:`Boolean (with NA) ` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | ++-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+ pandas has two ways to store strings. diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index ba700ba1e5f81..a8ae8c47b0d19 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -70,7 +70,7 @@ def to_numeric( - 'integer' or 'signed': smallest signed int dtype (min.: np.int8) - 'unsigned': smallest unsigned int dtype (min.: np.uint8) - - 'float': float dtype (min.: np.float32), float16 is not supported. + - 'float': smallest float dtype (min.: np.float32) As this behaviour is separate from the core conversion to numeric values, any errors raised during the downcasting