|
2 | 2 | # pylint: disable=E1101,E1103,W0232
|
3 | 3 | import datetime
|
4 | 4 | import warnings
|
| 5 | +from functools import reduce |
5 | 6 | from sys import getsizeof
|
6 | 7 |
|
7 | 8 | import numpy as np
|
@@ -2900,11 +2901,12 @@ def isin(self, values, level=None):
|
2900 | 2901 | return np.lib.arraysetops.in1d(labs, sought_labels)
|
2901 | 2902 |
|
2902 | 2903 | def searchsorted(self, arr):
|
2903 |
| - from functools import reduce |
2904 |
| - dtype = reduce(lambda x, y : x + y, [l.dtype.descr for l in self.levels], []) |
2905 |
| - return self.values.astype(dtype).searchsorted(np.asarray(arr, dtype=dtype)) |
| 2904 | + dtype = [l.dtype.descr for l in self.levels] |
| 2905 | + dtype = reduce(lambda x, y: x + y, dtype, []) |
| 2906 | + arr = np.asarray(arr, dtype=dtype) |
| 2907 | + values = self.values.astype(dtype) |
| 2908 | + return values.searchsorted(arr) |
2906 | 2909 |
|
2907 |
| - |
2908 | 2910 |
|
2909 | 2911 | MultiIndex._add_numeric_methods_disabled()
|
2910 | 2912 | MultiIndex._add_numeric_methods_add_sub_disabled()
|
@@ -2939,6 +2941,5 @@ def _sparsify(label_list, start=0, sentinel=''):
|
2939 | 2941 | return lzip(*result)
|
2940 | 2942 |
|
2941 | 2943 |
|
2942 |
| - |
2943 | 2944 | def _get_na_rep(dtype):
|
2944 | 2945 | return {np.datetime64: 'NaT', np.timedelta64: 'NaT'}.get(dtype, 'NaN')
|
0 commit comments