@@ -214,7 +214,7 @@ def contains(cat, key, container):
214
214
215
215
class Categorical (ExtensionArray , PandasObject ):
216
216
"""
217
- Represent a categorical variable in classic R / S-plus fashion
217
+ Represent a categorical variable in classic R / S-plus fashion.
218
218
219
219
`Categoricals` can only take on only a limited, and usually fixed, number
220
220
of possible values (`categories`). In contrast to statistical categorical
@@ -235,7 +235,7 @@ class Categorical(ExtensionArray, PandasObject):
235
235
The unique categories for this categorical. If not given, the
236
236
categories are assumed to be the unique values of `values` (sorted, if
237
237
possible, otherwise in the order in which they appear).
238
- ordered : boolean, ( default False)
238
+ ordered : bool, default False
239
239
Whether or not this categorical is treated as a ordered categorical.
240
240
If True, the resulting categorical will be ordered.
241
241
An ordered categorical respects, when sorted, the order of its
@@ -253,7 +253,7 @@ class Categorical(ExtensionArray, PandasObject):
253
253
codes : ndarray
254
254
The codes (integer positions, which point to the categories) of this
255
255
categorical, read only.
256
- ordered : boolean
256
+ ordered : bool
257
257
Whether or not this Categorical is ordered.
258
258
dtype : CategoricalDtype
259
259
The instance of ``CategoricalDtype`` storing the ``categories``
@@ -297,7 +297,7 @@ class Categorical(ExtensionArray, PandasObject):
297
297
Ordered `Categoricals` can be sorted according to the custom order
298
298
of the categories and can have a min and max value.
299
299
300
- >>> c = pd.Categorical(['a','b','c','a','b','c'], ordered=True,
300
+ >>> c = pd.Categorical(['a', 'b', 'c', 'a', 'b', 'c'], ordered=True,
301
301
... categories=['c', 'b', 'a'])
302
302
>>> c
303
303
[a, b, c, a, b, c]
@@ -618,7 +618,7 @@ def from_codes(cls, codes, categories=None, ordered=None, dtype=None):
618
618
----------
619
619
codes : array-like, integers
620
620
An integer array, where each integer points to a category in
621
- categories or dtype.categories, or else is -1 for NaN
621
+ categories or dtype.categories, or else is -1 for NaN.
622
622
categories : index-like, optional
623
623
The categories for the categorical. Items need to be unique.
624
624
If the categories are not given here, then they must be provided
@@ -700,7 +700,7 @@ def _set_categories(self, categories, fastpath=False):
700
700
701
701
Parameters
702
702
----------
703
- fastpath : boolean ( default: False)
703
+ fastpath : bool, default False
704
704
Don't perform validation of the categories for uniqueness or nulls
705
705
706
706
Examples
@@ -747,15 +747,15 @@ def _set_dtype(self, dtype):
747
747
748
748
def set_ordered (self , value , inplace = False ):
749
749
"""
750
- Set the ordered attribute to the boolean value
750
+ Set the ordered attribute to the boolean value.
751
751
752
752
Parameters
753
753
----------
754
- value : boolean to set whether this categorical is ordered (True) or
755
- not (False)
756
- inplace : boolean ( default: False)
757
- Whether or not to set the ordered attribute inplace or return a copy
758
- of this categorical with ordered set to the value
754
+ value : bool
755
+ Set whether this categorical is ordered (True) or not (False).
756
+ inplace : bool, default False
757
+ Whether or not to set the ordered attribute in-place or return
758
+ a copy of this categorical with ordered set to the value.
759
759
"""
760
760
inplace = validate_bool_kwarg (inplace , 'inplace' )
761
761
new_dtype = CategoricalDtype (self .categories , ordered = value )
@@ -770,9 +770,9 @@ def as_ordered(self, inplace=False):
770
770
771
771
Parameters
772
772
----------
773
- inplace : boolean ( default: False)
774
- Whether or not to set the ordered attribute inplace or return a copy
775
- of this categorical with ordered set to True
773
+ inplace : bool, default False
774
+ Whether or not to set the ordered attribute in-place or return
775
+ a copy of this categorical with ordered set to True.
776
776
"""
777
777
inplace = validate_bool_kwarg (inplace , 'inplace' )
778
778
return self .set_ordered (True , inplace = inplace )
@@ -783,9 +783,9 @@ def as_unordered(self, inplace=False):
783
783
784
784
Parameters
785
785
----------
786
- inplace : boolean ( default: False)
787
- Whether or not to set the ordered attribute inplace or return a copy
788
- of this categorical with ordered set to False
786
+ inplace : bool, default False
787
+ Whether or not to set the ordered attribute in-place or return
788
+ a copy of this categorical with ordered set to False.
789
789
"""
790
790
inplace = validate_bool_kwarg (inplace , 'inplace' )
791
791
return self .set_ordered (False , inplace = inplace )
@@ -815,19 +815,19 @@ def set_categories(self, new_categories, ordered=None, rename=False,
815
815
----------
816
816
new_categories : Index-like
817
817
The categories in new order.
818
- ordered : boolean, ( default: False)
818
+ ordered : bool, default False
819
819
Whether or not the categorical is treated as a ordered categorical.
820
820
If not given, do not change the ordered information.
821
- rename : boolean ( default: False)
821
+ rename : bool, default False
822
822
Whether or not the new_categories should be considered as a rename
823
823
of the old categories or as reordered categories.
824
- inplace : boolean ( default: False)
825
- Whether or not to reorder the categories inplace or return a copy of
826
- this categorical with reordered categories.
824
+ inplace : bool, default False
825
+ Whether or not to reorder the categories in-place or return a copy
826
+ of this categorical with reordered categories.
827
827
828
828
Returns
829
829
-------
830
- cat : Categorical with reordered categories or None if inplace.
830
+ Categorical with reordered categories or None if inplace.
831
831
832
832
Raises
833
833
------
@@ -890,7 +890,7 @@ def rename_categories(self, new_categories, inplace=False):
890
890
Currently, Series are considered list like. In a future version
891
891
of pandas they'll be considered dict-like.
892
892
893
- inplace : boolean ( default: False)
893
+ inplace : bool, default False
894
894
Whether or not to rename the categories inplace or return a copy of
895
895
this categorical with renamed categories.
896
896
@@ -967,10 +967,10 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):
967
967
----------
968
968
new_categories : Index-like
969
969
The categories in new order.
970
- ordered : boolean , optional
970
+ ordered : bool , optional
971
971
Whether or not the categorical is treated as a ordered categorical.
972
972
If not given, do not change the ordered information.
973
- inplace : boolean ( default: False)
973
+ inplace : bool, default False
974
974
Whether or not to reorder the categories inplace or return a copy of
975
975
this categorical with reordered categories.
976
976
@@ -1010,7 +1010,7 @@ def add_categories(self, new_categories, inplace=False):
1010
1010
----------
1011
1011
new_categories : category or list-like of category
1012
1012
The new categories to be included.
1013
- inplace : boolean ( default: False)
1013
+ inplace : bool, default False
1014
1014
Whether or not to add the categories inplace or return a copy of
1015
1015
this categorical with added categories.
1016
1016
@@ -1060,7 +1060,7 @@ def remove_categories(self, removals, inplace=False):
1060
1060
----------
1061
1061
removals : category or list of categories
1062
1062
The categories which should be removed.
1063
- inplace : boolean ( default: False)
1063
+ inplace : bool, default False
1064
1064
Whether or not to remove the categories inplace or return a copy of
1065
1065
this categorical with removed categories.
1066
1066
@@ -1108,7 +1108,7 @@ def remove_unused_categories(self, inplace=False):
1108
1108
1109
1109
Parameters
1110
1110
----------
1111
- inplace : boolean ( default: False)
1111
+ inplace : bool, default False
1112
1112
Whether or not to drop unused categories inplace or return a copy of
1113
1113
this categorical with unused categories dropped.
1114
1114
@@ -1460,7 +1460,7 @@ def value_counts(self, dropna=True):
1460
1460
1461
1461
Parameters
1462
1462
----------
1463
- dropna : boolean , default True
1463
+ dropna : bool , default True
1464
1464
Don't include counts of NaN.
1465
1465
1466
1466
Returns
@@ -1581,9 +1581,9 @@ def sort_values(self, inplace=False, ascending=True, na_position='last'):
1581
1581
1582
1582
Parameters
1583
1583
----------
1584
- inplace : boolean , default False
1584
+ inplace : bool , default False
1585
1585
Do operation in place.
1586
- ascending : boolean , default True
1586
+ ascending : bool , default True
1587
1587
Order ascending. Passing False orders descending. The
1588
1588
ordering parameter provides the method by which the
1589
1589
category values are organized.
@@ -2239,7 +2239,7 @@ def mode(self, dropna=True):
2239
2239
2240
2240
Parameters
2241
2241
----------
2242
- dropna : boolean , default True
2242
+ dropna : bool , default True
2243
2243
Don't consider counts of NaN/NaT.
2244
2244
2245
2245
.. versionadded:: 0.24.0
@@ -2332,7 +2332,7 @@ def equals(self, other):
2332
2332
2333
2333
Returns
2334
2334
-------
2335
- are_equal : boolean
2335
+ bool
2336
2336
"""
2337
2337
if self .is_dtype_equal (other ):
2338
2338
if self .categories .equals (other .categories ):
@@ -2356,7 +2356,7 @@ def is_dtype_equal(self, other):
2356
2356
2357
2357
Returns
2358
2358
-------
2359
- are_equal : boolean
2359
+ bool
2360
2360
"""
2361
2361
2362
2362
try :
0 commit comments