Skip to content

DOC: Add strings for dtypes in basic.rst #30628

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 5 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
41 changes: 28 additions & 13 deletions doc/source/getting_started/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1937,21 +1937,36 @@ See :ref:`extending.extension-types` for how to write your own extension that
works with pandas. See :ref:`ecosystem.extensions` for a list of third-party
libraries that have implemented an extension.

The following table lists all of pandas extension types. See the respective
The following table lists all of pandas extension types. For methods requiring ``dtype``
arguments, strings can be specified as indicated. See the respective
documentation sections for more on each type.

=================== ========================= ================== ============================= =============================
Kind of Data Data Type Scalar Array Documentation
=================== ========================= ================== ============================= =============================
tz-aware datetime :class:`DatetimeTZDtype` :class:`Timestamp` :class:`arrays.DatetimeArray` :ref:`timeseries.timezone`
Categorical :class:`CategoricalDtype` (none) :class:`Categorical` :ref:`categorical`
period (time spans) :class:`PeriodDtype` :class:`Period` :class:`arrays.PeriodArray` :ref:`timeseries.periods`
sparse :class:`SparseDtype` (none) :class:`arrays.SparseArray` :ref:`sparse`
intervals :class:`IntervalDtype` :class:`Interval` :class:`arrays.IntervalArray` :ref:`advanced.intervalindex`
nullable integer :class:`Int64Dtype`, ... (none) :class:`arrays.IntegerArray` :ref:`integer_na`
Strings :class:`StringDtype` :class:`str` :class:`arrays.StringArray` :ref:`text`
Boolean (with NA) :class:`BooleanDtype` :class:`bool` :class:`arrays.BooleanArray` :ref:`api.arrays.bool`
=================== ========================= ================== ============================= =============================
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
|Kind of Data | Data Type | Scalar | Array | String Aliases | Documentation |
+==================+===========================+====================+===============================+=========================================+===============================+
|tz-aware datetime | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, <tz>]'`` | :ref:`timeseries.timezone` |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
|Categorical | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | :ref:`categorical` |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
|period | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[<freq>]'``, | :ref:`timeseries.periods` |
|(time spans) | | | | ``'Period[<freq>]'`` | |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
|sparse | :class:`SparseDtype` | (none) | :class:`arrays.SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | :ref:`sparse` |
| | | | | ``'Sparse[float]'`` | |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
| intervals | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | :ref:`advanced.intervalindex` |
| | | | | ``'Interval[<numpy_dtype>]'``, | |
| | | | | ``'Interval[datetime64[ns, <tz>]]'``, | |
| | | | | ``'Interval[timedelta64[<freq>]]'`` | |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
| nullable integer + :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | :ref:`integer_na` |
| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``, | |
| | | | | ``'UInt32'``, ``'UInt64'`` | |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
| Strings | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | :ref:`text` |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
| Boolean (with NA)| :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | :ref:`api.arrays.bool` |
+------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+

Pandas has two ways to store strings.

Expand Down
3 changes: 2 additions & 1 deletion doc/source/reference/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ For most data types, pandas uses NumPy arrays as the concrete
objects contained with a :class:`Index`, :class:`Series`, or
:class:`DataFrame`.

For some data types, pandas extends NumPy's type system.
For some data types, pandas extends NumPy's type system. String aliases for these types
can be found at :ref:`basics.dtypes`.

=================== ========================= ================== =============================
Kind of Data Pandas Data Type Scalar Array
Expand Down