Skip to content

Commit e946e08

Browse files
committed
linting
1 parent 563dc04 commit e946e08

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pandas/core/indexes/multi.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# pylint: disable=E1101,E1103,W0232
33
import datetime
44
import warnings
5+
from functools import reduce
56
from sys import getsizeof
67

78
import numpy as np
@@ -2900,11 +2901,12 @@ def isin(self, values, level=None):
29002901
return np.lib.arraysetops.in1d(labs, sought_labels)
29012902

29022903
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)
29062909

2907-
29082910

29092911
MultiIndex._add_numeric_methods_disabled()
29102912
MultiIndex._add_numeric_methods_add_sub_disabled()
@@ -2939,6 +2941,5 @@ def _sparsify(label_list, start=0, sentinel=''):
29392941
return lzip(*result)
29402942

29412943

2942-
29432944
def _get_na_rep(dtype):
29442945
return {np.datetime64: 'NaT', np.timedelta64: 'NaT'}.get(dtype, 'NaN')

pandas/tests/indexes/multi/test_indexing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def test_get_indexer_categorical_time():
347347
result = midx.get_indexer(midx)
348348
tm.assert_numpy_array_equal(result, np.arange(9, dtype=np.intp))
349349

350+
350351
def test_searchsorted():
351352
i = MultiIndex.from_tuples([('a', 0), ('b', 1)]).searchsorted(('b', 0))
352353
assert i == 1

0 commit comments

Comments
 (0)