Skip to content

Commit 8364e7c

Browse files
committed
fixup! ENH: Parametrized CategoricalDtype
1 parent 91752fe commit 8364e7c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

doc/source/categorical.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ Anywhere above we passed a keyword ``dtype='category'``, we used the default beh
9595
2. categories are unordered.
9696

9797
To control those behaviors, instead of passing ``'category'``, use an instance
98-
of :class:`~pd.api.types.CategoricalDtype`.
98+
of :class:`~pandas.api.types.CategoricalDtype`.
9999

100100
.. ipython:: python
101101
102102
from pandas.api.types import CategoricalDtype
103103
104104
s = pd.Series(["a", "b", "c", "a"])
105105
cat_type = CategoricalDtype(categories=["b", "c", "d"],
106-
ordered=False)
106+
ordered=True)
107107
s_cat = s.astype(cat_type)
108108
s_cat
109109
@@ -181,9 +181,9 @@ array. In other words, ``dtype='category'`` is equivalent to
181181
Equality Semantics
182182
~~~~~~~~~~~~~~~~~~
183183

184-
Two instances of :class:`~pandas.api.types.CategoricalDtype` compare equal whenever the have
185-
the same categories and orderedness. When comparing two unordered categoricals, the
186-
order of the ``categories`` is not considered
184+
Two instances of :class:`~pandas.api.types.CategoricalDtype` compare equal
185+
whenever they have the same categories and orderedness. When comparing two
186+
unordered categoricals, the order of the ``categories`` is not considered
187187

188188
.. ipython:: python
189189

doc/source/whatsnew/v0.21.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ e.g., when converting string data to a ``Categorical``:
112112
The ``.dtype`` property of a ``Categorical``, ``CategoricalIndex`` or a
113113
``Series`` with categorical type will now return an instance of ``CategoricalDtype``.
114114

115-
See :ref:`CategoricalDtype <categorical.categoricaldtype>` for more.
115+
See the :ref:`CategoricalDtype docs <categorical.categoricaldtype>` for more.
116116

117117
.. _whatsnew_0210.enhancements.other:
118118

pandas/core/dtypes/dtypes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ class CategoricalDtype(ExtensionDtype):
130130
Examples
131131
--------
132132
>>> t = CategoricalDtype(categories=['b', 'a'], ordered=True)
133-
>>> s = Series(['a', 'a', 'b', 'b', 'a'], dtype=t)
134133
>>> pd.Series(['a', 'b', 'a', 'c'], dtype=t)
135134
0 a
136135
1 b
@@ -205,7 +204,7 @@ def __eq__(self, other):
205204
return hash(self) == hash(other)
206205

207206
def __unicode__(self):
208-
tpl = u'CategoricalDtype({}ordered={})'
207+
tpl = u'CategoricalDtype(categories={}ordered={})'
209208
if self.categories is None:
210209
data = u"None, "
211210
else:

0 commit comments

Comments
 (0)