@@ -147,16 +147,16 @@ class CategoricalIndex(NDArrayBackedExtensionIndex):
147
147
148
148
Examples
149
149
--------
150
- >>> pd.CategoricalIndex(["a", "b", "c", "a", "b", "c"])
150
+ >>> pd.CategoricalIndex(["a", "b", "c", "a", "b", "c"], orderer=True )
151
151
CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'],
152
- categories=['a', 'b', 'c'], ordered=False , dtype='category')
152
+ categories=['a', 'b', 'c'], ordered=True , dtype='category[object] ')
153
153
154
154
``CategoricalIndex`` can also be instantiated from a ``Categorical``:
155
155
156
- >>> c = pd.Categorical(["a", "b", "c", "a", "b", "c"])
156
+ >>> c = pd.Categorical(["a", "b", "c", "a", "b", "c"], ordered=True )
157
157
>>> pd.CategoricalIndex(c)
158
158
CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'],
159
- categories=['a', 'b', 'c'], ordered=False , dtype='category')
159
+ categories=['a', 'b', 'c'], ordered=True , dtype='category[object] ')
160
160
161
161
Ordered ``CategoricalIndex`` can have a min and max value.
162
162
@@ -165,7 +165,7 @@ class CategoricalIndex(NDArrayBackedExtensionIndex):
165
165
... )
166
166
>>> ci
167
167
CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'],
168
- categories=['c', 'b', 'a'], ordered=True, dtype='category')
168
+ categories=['c', 'b', 'a'], ordered=True, dtype='category[object] ')
169
169
>>> ci.min()
170
170
'c'
171
171
"""
@@ -438,24 +438,24 @@ def map(self, mapper, na_action: Literal["ignore"] | None = None):
438
438
>>> idx = pd.CategoricalIndex(['a', 'b', 'c'])
439
439
>>> idx
440
440
CategoricalIndex(['a', 'b', 'c'], categories=['a', 'b', 'c'],
441
- ordered=False, dtype='category')
441
+ ordered=False, dtype='category[object] ')
442
442
>>> idx.map(lambda x: x.upper())
443
443
CategoricalIndex(['A', 'B', 'C'], categories=['A', 'B', 'C'],
444
- ordered=False, dtype='category')
444
+ ordered=False, dtype='category[object] ')
445
445
>>> idx.map({'a': 'first', 'b': 'second', 'c': 'third'})
446
446
CategoricalIndex(['first', 'second', 'third'], categories=['first',
447
- 'second', 'third'], ordered=False, dtype='category')
447
+ 'second', 'third'], ordered=False, dtype='category[object] ')
448
448
449
449
If the mapping is one-to-one the ordering of the categories is
450
450
preserved:
451
451
452
452
>>> idx = pd.CategoricalIndex(['a', 'b', 'c'], ordered=True)
453
453
>>> idx
454
454
CategoricalIndex(['a', 'b', 'c'], categories=['a', 'b', 'c'],
455
- ordered=True, dtype='category')
455
+ ordered=True, dtype='category[object] ')
456
456
>>> idx.map({'a': 3, 'b': 2, 'c': 1})
457
457
CategoricalIndex([3, 2, 1], categories=[3, 2, 1], ordered=True,
458
- dtype='category')
458
+ dtype='category[int64] ')
459
459
460
460
If the mapping is not one-to-one an :class:`~pandas.Index` is returned:
461
461
0 commit comments