Skip to content

DOC: list supported float dtypes I #50738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 36 additions & 27 deletions doc/source/user_guide/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <timeseries.timezone>` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, <tz>]'`` |
| | | | | |
+-------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+
| :ref:`Categorical <categorical>` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` |
+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`period (time spans) <timeseries.periods>` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[<freq>]'``, |
| | | | ``'Period[<freq>]'`` | |
+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`sparse <sparse>` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, |
| | | | | ``'Sparse[float]'`` |
+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`intervals <advanced.intervalindex>` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, |
| | | | | ``'Interval[<numpy_dtype>]'``, |
| | | | | ``'Interval[datetime64[ns, <tz>]]'``, |
| | | | | ``'Interval[timedelta64[<freq>]]'`` |
+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`nullable integer <integer_na>` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, |
| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,|
| | | | | ``'UInt32'``, ``'UInt64'`` |
+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`Strings <text>` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` |
+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`Boolean (with NA) <api.arrays.bool>` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` |
+-------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you post a screenshot of how this looks? It's somewhat hard to see what changed from the diff

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, the issue is fixed? Right ! or can i still push my changes? I am new in open source

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if interested in contributing you can find an issue that hasn't been assigned yet or doesn't have an open pull request

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thank you. So on an issue only one person can pull a request at one time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks mroeschke

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dtypes_pandas

This is a screenshot of that part of the table.
As Marco said, there is no need to add NumPy integer and NumPy float to the table of pandas extension types. I corrected the table and left only "nullable float" under "nullable integer" (without the rest). This implies that we shouldn’t resize the table.

| Kind of Data | Data Type | Scalar | Array | String Aliases |
+=============================================================================================+===============+===========+========+===========+===============================+========================================+
| :ref:`tz-aware datetime <timeseries.timezone>` | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, <tz>]'`` |
| | | | | |
+---------------------------------------------------------------------------------------------+---------------+-----------+--------------------+-------------------------------+----------------------------------------+
| :ref:`Categorical <categorical>` | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`period (time spans) <timeseries.periods>` | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[<freq>]'``, |
| | | | ``'Period[<freq>]'`` | |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`sparse <sparse>` | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, |
| | | | | ``'Sparse[float]'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`intervals <advanced.intervalindex>` | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, |
| | | | | ``'Interval[<numpy_dtype>]'``, |
| | | | | ``'Interval[datetime64[ns, <tz>]]'``, |
| | | | | ``'Interval[timedelta64[<freq>]]'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`nullable integer <integer_na>` | :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, |
| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``,|
| | | | | ``'UInt32'``, ``'UInt64'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| `NumPy integer <https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.integer>`_ | :class:`numpy.integer` | :class:`int` | :class:`arrays.IntegerArray` | ``'int8'``, ``'int16'``, ``'int32'``, |
| | | | | ``'int64'``, ``'uint8'``, ``'uint16'``,|
| | | | | ``'uint32'``, ``'uint64'`` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs adding, as this table says

The following table lists all of pandas extension types

All that needs adding is "nullable float" under "nullable integer"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @MarcoGorelli . As you suggested, I added "nullable float" to the table and removed integer and float.

I noticed that there is no link to “nullable float”
Wouldn’t be useful to have a description and examples for “nullable float”, as we have for “nullable integer”

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, maybe - currently there's no user guide page on nullable floats, but perhaps there should be

+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| ``nullable float`` | :class:`Float64Dtype`, ...| (none) | :class:`arrays.FloatingArray` | ``'Float32'``, ``'Float64'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| `NumPy float <https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.floating>`_ | :class:`numpy.floating` | :class:`float` | :class:`arrays.FloatingArray` | ``'float16'``, ``'float32'``, |
| | | | | ``'float64'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`Strings <text>` | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+
| :ref:`Boolean (with NA) <api.arrays.bool>` | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` |
+---------------------------------------------------------------------------------------------+---------------------------+--------------------+-------------------------------+----------------------------------------+

pandas has two ways to store strings.

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/tools/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I think this one's clear enough as it is - if it says min: np.float32, then that already implies float16 not being supported

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point. After re-consideration, I agree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's revert this change


As this behaviour is separate from the core conversion to
numeric values, any errors raised during the downcasting
Expand Down