Skip to content

Commit 0ebd0d8

Browse files
committed
BUG: incorrect conversion on isin algos with m8
1 parent 0caf685 commit 0ebd0d8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pandas/core/algorithms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def isin(comps, values):
174174
" to isin(), you passed a "
175175
"[{0}]".format(type(values).__name__))
176176

177-
from pandas import DatetimeIndex, PeriodIndex
177+
from pandas import DatetimeIndex, TimedeltaIndex, PeriodIndex
178178

179179
if not isinstance(values, (ABCIndex, ABCSeries, np.ndarray)):
180180
values = np.array(list(values), dtype='object')
@@ -183,6 +183,9 @@ def isin(comps, values):
183183
if is_period_dtype(values):
184184
comps = PeriodIndex(comps)
185185
values = PeriodIndex(values)
186+
elif is_timedelta64_dtype(comps):
187+
comps = TimedeltaIndex(comps)
188+
values = TimedeltaIndex(values)
186189
else:
187190
comps = DatetimeIndex(comps)
188191
values = DatetimeIndex(values)

pandas/tests/test_algos.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ def test_basic(self):
431431
expected = np.array([False, False])
432432
tm.assert_numpy_array_equal(result, expected)
433433

434+
def test_i8(self):
435+
434436
arr = pd.date_range('20130101', periods=3).values
435437
result = algos.isin(arr, [arr[0]])
436438
expected = np.array([True, False, False])

0 commit comments

Comments
 (0)