Skip to content

Commit 9fb3040

Browse files
Dr-Irvdatapythonista
authored andcommitted
DOC: Add strings for dtypes in basic.rst (#30628)
1 parent b9de33e commit 9fb3040

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

doc/source/getting_started/basics.rst

+28-13
Original file line numberDiff line numberDiff line change
@@ -1937,21 +1937,36 @@ See :ref:`extending.extension-types` for how to write your own extension that
19371937
works with pandas. See :ref:`ecosystem.extensions` for a list of third-party
19381938
libraries that have implemented an extension.
19391939

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

1943-
=================== ========================= ================== ============================= =============================
1944-
Kind of Data Data Type Scalar Array Documentation
1945-
=================== ========================= ================== ============================= =============================
1946-
tz-aware datetime :class:`DatetimeTZDtype` :class:`Timestamp` :class:`arrays.DatetimeArray` :ref:`timeseries.timezone`
1947-
Categorical :class:`CategoricalDtype` (none) :class:`Categorical` :ref:`categorical`
1948-
period (time spans) :class:`PeriodDtype` :class:`Period` :class:`arrays.PeriodArray` :ref:`timeseries.periods`
1949-
sparse :class:`SparseDtype` (none) :class:`arrays.SparseArray` :ref:`sparse`
1950-
intervals :class:`IntervalDtype` :class:`Interval` :class:`arrays.IntervalArray` :ref:`advanced.intervalindex`
1951-
nullable integer :class:`Int64Dtype`, ... (none) :class:`arrays.IntegerArray` :ref:`integer_na`
1952-
Strings :class:`StringDtype` :class:`str` :class:`arrays.StringArray` :ref:`text`
1953-
Boolean (with NA) :class:`BooleanDtype` :class:`bool` :class:`arrays.BooleanArray` :ref:`api.arrays.bool`
1954-
=================== ========================= ================== ============================= =============================
1944+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1945+
| Kind of Data | Data Type | Scalar | Array | String Aliases | Documentation |
1946+
+===================+===========================+====================+===============================+=========================================+===============================+
1947+
| tz-aware datetime | :class:`DatetimeTZDtype` | :class:`Timestamp` | :class:`arrays.DatetimeArray` | ``'datetime64[ns, <tz>]'`` | :ref:`timeseries.timezone` |
1948+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1949+
| Categorical | :class:`CategoricalDtype` | (none) | :class:`Categorical` | ``'category'`` | :ref:`categorical` |
1950+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1951+
| period | :class:`PeriodDtype` | :class:`Period` | :class:`arrays.PeriodArray` | ``'period[<freq>]'``, | :ref:`timeseries.periods` |
1952+
| (time spans) | | | | ``'Period[<freq>]'`` | |
1953+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1954+
| sparse | :class:`SparseDtype` | (none) | :class:`SparseArray` | ``'Sparse'``, ``'Sparse[int]'``, | :ref:`sparse` |
1955+
| | | | | ``'Sparse[float]'`` | |
1956+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1957+
| intervals | :class:`IntervalDtype` | :class:`Interval` | :class:`arrays.IntervalArray` | ``'interval'``, ``'Interval'``, | :ref:`advanced.intervalindex` |
1958+
| | | | | ``'Interval[<numpy_dtype>]'``, | |
1959+
| | | | | ``'Interval[datetime64[ns, <tz>]]'``, | |
1960+
| | | | | ``'Interval[timedelta64[<freq>]]'`` | |
1961+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1962+
| nullable integer + :class:`Int64Dtype`, ... | (none) | :class:`arrays.IntegerArray` | ``'Int8'``, ``'Int16'``, ``'Int32'``, | :ref:`integer_na` |
1963+
| | | | | ``'Int64'``, ``'UInt8'``, ``'UInt16'``, | |
1964+
| | | | | ``'UInt32'``, ``'UInt64'`` | |
1965+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1966+
| Strings | :class:`StringDtype` | :class:`str` | :class:`arrays.StringArray` | ``'string'`` | :ref:`text` |
1967+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
1968+
| Boolean (with NA) | :class:`BooleanDtype` | :class:`bool` | :class:`arrays.BooleanArray` | ``'boolean'`` | :ref:`api.arrays.bool` |
1969+
+-------------------+---------------------------+--------------------+-------------------------------+-----------------------------------------+-------------------------------+
19551970

19561971
Pandas has two ways to store strings.
19571972

doc/source/reference/arrays.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ For most data types, pandas uses NumPy arrays as the concrete
1212
objects contained with a :class:`Index`, :class:`Series`, or
1313
:class:`DataFrame`.
1414

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

1718
=================== ========================= ================== =============================
1819
Kind of Data Pandas Data Type Scalar Array

0 commit comments

Comments
 (0)