@@ -273,6 +273,16 @@ class Categorical(ExtensionArray, PandasObject):
273
273
If an explicit ``ordered=True`` is given but no `categories` and the
274
274
`values` are not sortable.
275
275
276
+ See Also
277
+ --------
278
+ pandas.api.types.CategoricalDtype : Type for categorical data.
279
+ CategoricalIndex : An Index with an underlying ``Categorical``.
280
+
281
+ Notes
282
+ -----
283
+ See the `user guide
284
+ <http://pandas.pydata.org/pandas-docs/stable/categorical.html>`_ for more.
285
+
276
286
Examples
277
287
--------
278
288
>>> pd.Categorical([1, 2, 3, 1, 2, 3])
@@ -293,16 +303,6 @@ class Categorical(ExtensionArray, PandasObject):
293
303
Categories (3, object): [c < b < a]
294
304
>>> c.min()
295
305
'c'
296
-
297
- Notes
298
- -----
299
- See the `user guide
300
- <http://pandas.pydata.org/pandas-docs/stable/categorical.html>`_ for more.
301
-
302
- See Also
303
- --------
304
- pandas.api.types.CategoricalDtype : Type for categorical data.
305
- CategoricalIndex : An Index with an underlying ``Categorical``.
306
306
"""
307
307
308
308
# For comparisons, so that numpy uses our implementation if the compare
@@ -827,11 +827,6 @@ def set_categories(self, new_categories, ordered=None, rename=False,
827
827
dtypes on python3, which does not considers a S1 string equal to a
828
828
single char python string.
829
829
830
- Raises
831
- ------
832
- ValueError
833
- If new_categories does not validate as categories
834
-
835
830
Parameters
836
831
----------
837
832
new_categories : Index-like
@@ -850,6 +845,11 @@ def set_categories(self, new_categories, ordered=None, rename=False,
850
845
-------
851
846
cat : Categorical with reordered categories or None if inplace.
852
847
848
+ Raises
849
+ ------
850
+ ValueError
851
+ If new_categories does not validate as categories
852
+
853
853
See Also
854
854
--------
855
855
rename_categories
@@ -882,12 +882,6 @@ def rename_categories(self, new_categories, inplace=False):
882
882
"""
883
883
Renames categories.
884
884
885
- Raises
886
- ------
887
- ValueError
888
- If new categories are list-like and do not have the same number of
889
- items than the current categories or do not validate as categories
890
-
891
885
Parameters
892
886
----------
893
887
new_categories : list-like, dict-like or callable
@@ -922,6 +916,12 @@ def rename_categories(self, new_categories, inplace=False):
922
916
With ``inplace=False``, the new categorical is returned.
923
917
With ``inplace=True``, there is no return value.
924
918
919
+ Raises
920
+ ------
921
+ ValueError
922
+ If new categories are list-like and do not have the same number of
923
+ items than the current categories or do not validate as categories
924
+
925
925
See Also
926
926
--------
927
927
reorder_categories
@@ -979,12 +979,6 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):
979
979
`new_categories` need to include all old categories and no new category
980
980
items.
981
981
982
- Raises
983
- ------
984
- ValueError
985
- If the new categories do not contain all old category items or any
986
- new ones
987
-
988
982
Parameters
989
983
----------
990
984
new_categories : Index-like
@@ -1000,6 +994,12 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):
1000
994
-------
1001
995
cat : Categorical with reordered categories or None if inplace.
1002
996
997
+ Raises
998
+ ------
999
+ ValueError
1000
+ If the new categories do not contain all old category items or any
1001
+ new ones
1002
+
1003
1003
See Also
1004
1004
--------
1005
1005
rename_categories
@@ -1022,12 +1022,6 @@ def add_categories(self, new_categories, inplace=False):
1022
1022
`new_categories` will be included at the last/highest place in the
1023
1023
categories and will be unused directly after this call.
1024
1024
1025
- Raises
1026
- ------
1027
- ValueError
1028
- If the new categories include old categories or do not validate as
1029
- categories
1030
-
1031
1025
Parameters
1032
1026
----------
1033
1027
new_categories : category or list-like of category
@@ -1040,6 +1034,12 @@ def add_categories(self, new_categories, inplace=False):
1040
1034
-------
1041
1035
cat : Categorical with new categories added or None if inplace.
1042
1036
1037
+ Raises
1038
+ ------
1039
+ ValueError
1040
+ If the new categories include old categories or do not validate as
1041
+ categories
1042
+
1043
1043
See Also
1044
1044
--------
1045
1045
rename_categories
@@ -1072,11 +1072,6 @@ def remove_categories(self, removals, inplace=False):
1072
1072
`removals` must be included in the old categories. Values which were in
1073
1073
the removed categories will be set to NaN
1074
1074
1075
- Raises
1076
- ------
1077
- ValueError
1078
- If the removals are not contained in the categories
1079
-
1080
1075
Parameters
1081
1076
----------
1082
1077
removals : category or list of categories
@@ -1089,6 +1084,11 @@ def remove_categories(self, removals, inplace=False):
1089
1084
-------
1090
1085
cat : Categorical with removed categories or None if inplace.
1091
1086
1087
+ Raises
1088
+ ------
1089
+ ValueError
1090
+ If the removals are not contained in the categories
1091
+
1092
1092
See Also
1093
1093
--------
1094
1094
rename_categories
0 commit comments