@@ -986,7 +986,7 @@ not noted for a particular column will be ``NaN``:
986
986
987
987
tsdf.agg({' A' : [' mean' , ' min' ], ' B' : ' sum' })
988
988
989
- .. _basics.aggregation.mixed_dtypes :
989
+ .. _basics.aggregation.mixed_string :
990
990
991
991
Mixed dtypes
992
992
++++++++++++
@@ -1704,14 +1704,21 @@ built-in string methods. For example:
1704
1704
1705
1705
.. ipython :: python
1706
1706
1707
- s = pd.Series([' A' , ' B' , ' C' , ' Aaba' , ' Baca' , np.nan, ' CABA' , ' dog' , ' cat' ])
1707
+ s = pd.Series([' A' , ' B' , ' C' , ' Aaba' , ' Baca' , np.nan, ' CABA' , ' dog' , ' cat' ],
1708
+ dtype = " string" )
1708
1709
s.str.lower()
1709
1710
1710
1711
Powerful pattern-matching methods are provided as well, but note that
1711
1712
pattern-matching generally uses `regular expressions
1712
1713
<https://docs.python.org/3/library/re.html> `__ by default (and in some cases
1713
1714
always uses them).
1714
1715
1716
+ .. note ::
1717
+
1718
+ Prior to pandas 1.0, string methods were only available on ``object `` -dtype
1719
+ ``Series ``. Pandas 1.0 added the :class: `StringDtype ` which is dedicated
1720
+ to strings. See :ref: `text.types ` for more.
1721
+
1715
1722
Please see :ref: `Vectorized String Methods <text.string_methods >` for a complete
1716
1723
description.
1717
1724
@@ -1925,9 +1932,15 @@ period (time spans) :class:`PeriodDtype` :class:`Period` :class:`arrays.
1925
1932
sparse :class: `SparseDtype ` (none) :class: `arrays.SparseArray ` :ref: `sparse `
1926
1933
intervals :class: `IntervalDtype ` :class: `Interval ` :class: `arrays.IntervalArray ` :ref: `advanced.intervalindex `
1927
1934
nullable integer :class: `Int64Dtype `, ... (none) :class: `arrays.IntegerArray ` :ref: `integer_na `
1935
+ Strings :class: `StringDtype ` :class: `str ` :class: `arrays.StringArray ` :ref: `text `
1928
1936
=================== ========================= ================== ============================= =============================
1929
1937
1930
- Pandas uses the ``object `` dtype for storing strings.
1938
+ Pandas has two ways to store strings.
1939
+
1940
+ 1. ``object `` dtype, which can hold any Python object, including strings.
1941
+ 2. :class: `StringDtype `, which is dedicated to strings.
1942
+
1943
+ Generally, we recommend using :class: `StringDtype `. See :ref: `text.types ` fore more.
1931
1944
1932
1945
Finally, arbitrary objects may be stored using the ``object `` dtype, but should
1933
1946
be avoided to the extent possible (for performance and interoperability with
0 commit comments