@@ -199,17 +199,6 @@ def contains(cat, key, container):
199
199
return any (loc_ in container for loc_ in loc )
200
200
201
201
202
- _codes_doc = """
203
- The category codes of this categorical.
204
-
205
- Level codes are an array if integer which are the positions of the real
206
- values in the categories array.
207
-
208
- There is not setter, use the other categorical methods and the normal item
209
- setter to change values in the categorical.
210
- """
211
-
212
-
213
202
class Categorical (ExtensionArray , PandasObject ):
214
203
"""
215
204
Represent a categorical variable in classic R / S-plus fashion.
@@ -652,27 +641,26 @@ def from_codes(cls, codes, categories=None, ordered=None, dtype=None):
652
641
653
642
return cls (codes , dtype = dtype , fastpath = True )
654
643
655
- def _get_codes (self ):
644
+ @property
645
+ def codes (self ) -> np .ndarray :
656
646
"""
657
- Get the codes.
647
+ The category codes of this categorical.
648
+
649
+ Codes are an array of integers which are the positions of the actual
650
+ values in the categories array.
651
+
652
+ There is no setter, use the other categorical methods and the normal item
653
+ setter to change values in the categorical.
658
654
659
655
Returns
660
656
-------
661
- codes : integer array view
662
- A non writable view of the `codes` array.
657
+ ndarray[int]
658
+ A non- writable view of the `codes` array.
663
659
"""
664
660
v = self ._codes .view ()
665
661
v .flags .writeable = False
666
662
return v
667
663
668
- def _set_codes (self , codes ):
669
- """
670
- Not settable by the user directly
671
- """
672
- raise ValueError ("cannot set Categorical codes directly" )
673
-
674
- codes = property (fget = _get_codes , fset = _set_codes , doc = _codes_doc )
675
-
676
664
def _set_categories (self , categories , fastpath = False ):
677
665
"""
678
666
Sets new categories inplace
0 commit comments