@@ -2601,7 +2601,7 @@ def _can_union_without_object_cast(self, other) -> bool:
2601
2601
2602
2602
@final
2603
2603
def _validate_sort_keyword (self , sort ):
2604
- if sort not in [None , False ]:
2604
+ if sort not in [None , False , True ]:
2605
2605
raise ValueError (
2606
2606
"The 'sort' keyword only takes the values of "
2607
2607
f"None or False; { sort } was passed."
@@ -2662,6 +2662,9 @@ def union(self, other, sort=None):
2662
2662
self ._assert_can_do_setop (other )
2663
2663
other = ensure_index (other )
2664
2664
2665
+ if sort == True :
2666
+ sort = None
2667
+
2665
2668
if not self ._can_union_without_object_cast (other ):
2666
2669
return self ._union_incompatible_dtypes (other , sort = sort )
2667
2670
@@ -2790,6 +2793,9 @@ def intersection(self, other, sort=False):
2790
2793
self ._assert_can_do_setop (other )
2791
2794
other = ensure_index (other )
2792
2795
2796
+ if sort == True :
2797
+ sort = None
2798
+
2793
2799
if self .equals (other ):
2794
2800
return self ._get_reconciled_name_object (other )
2795
2801
@@ -2867,6 +2873,9 @@ def difference(self, other, sort=None):
2867
2873
self ._validate_sort_keyword (sort )
2868
2874
self ._assert_can_do_setop (other )
2869
2875
2876
+ if sort == True :
2877
+ sort = None
2878
+
2870
2879
if self .equals (other ):
2871
2880
# pass an empty np.ndarray with the appropriate dtype
2872
2881
return self ._shallow_copy (self ._data [:0 ])
@@ -2938,6 +2947,10 @@ def symmetric_difference(self, other, result_name=None, sort=None):
2938
2947
self ._validate_sort_keyword (sort )
2939
2948
self ._assert_can_do_setop (other )
2940
2949
other , result_name_update = self ._convert_can_do_setop (other )
2950
+
2951
+ if sort == True :
2952
+ sort = None
2953
+
2941
2954
if result_name is None :
2942
2955
result_name = result_name_update
2943
2956
@@ -5200,8 +5213,13 @@ def _maybe_cast_slice_bound(self, label, side: str_t, kind):
5200
5213
# We are a plain index here (sub-class override this method if they
5201
5214
# wish to have special treatment for floats/ints, e.g. Float64Index and
5202
5215
# datetimelike Indexes
5203
- # reject them, if index does not contain label
5204
- if (is_float (label ) or is_integer (label )) and label not in self .values :
5216
+ # reject them
5217
+ if is_float (label ):
5218
+ self ._invalid_indexer ("slice" , label )
5219
+
5220
+ # we are trying to find integer bounds on a non-integer based index
5221
+ # this is rejected (generally .loc gets you here)
5222
+ elif is_integer (label ):
5205
5223
self ._invalid_indexer ("slice" , label )
5206
5224
5207
5225
return label
0 commit comments