File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -4533,6 +4533,8 @@ def sort_index(
4533
4533
4534
4534
inplace = validate_bool_kwarg (inplace , "inplace" )
4535
4535
axis = self ._get_axis_number (axis )
4536
+ ascending = validate_ascending (ascending )
4537
+
4536
4538
target = self ._get_axis (axis )
4537
4539
4538
4540
indexer = get_indexer_indexer (
@@ -11772,3 +11774,25 @@ def _doc_params(cls):
11772
11774
The required number of valid values to perform the operation. If fewer than
11773
11775
``min_count`` non-NA values are present the result will be NA.
11774
11776
"""
11777
+
11778
+
11779
+ def validate_ascending (
11780
+ ascending : Union [bool , Sequence [bool ]],
11781
+ ) -> Union [bool , Sequence [bool ]]:
11782
+ """Validate ``ascending`` kwargs for ``sort_index`` method."""
11783
+ if not isinstance (ascending , (list , tuple )):
11784
+ _check_ascending_element (ascending )
11785
+ return ascending
11786
+
11787
+ for item in ascending :
11788
+ _check_ascending_element (item )
11789
+ return ascending
11790
+
11791
+
11792
+ def _check_ascending_element (value ):
11793
+ """Ensure that each item in ``ascending`` kwarg is either bool or int."""
11794
+ if (
11795
+ value is None
11796
+ or not isinstance (value , (bool , int ))
11797
+ ):
11798
+ raise ValueError ("ascending must be either a bool or a sequence of bools" )
You can’t perform that action at this time.
0 commit comments