We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e5f6245 commit 0ea7348Copy full SHA for 0ea7348
pandas/core/algorithms.py
@@ -404,9 +404,12 @@ def isin(comps, values):
404
if not isinstance(values, (ABCIndex, ABCSeries, np.ndarray)):
405
values = construct_1d_object_array_from_listlike(list(values))
406
407
+ from pandas.core.dtypes.common import is_datetimelike
408
comps, dtype, _ = _ensure_data(comps)
- if (all(is_datetime_or_timedelta_dtype(i) for i in values) and
409
- is_datetime_or_timedelta_dtype(dtype)):
+ # Convert `values` to `dtype` if `values` is datetime-like and `dtype` is datetime-like
410
+ if (is_datetime_or_timedelta_dtype(dtype) and
411
+ (is_datetime_or_timedelta_dtype(values) or
412
+ all(is_datetimelike(i) for i in values))):
413
values, _, _ = _ensure_data(values, dtype=dtype)
414
else:
415
values, _, _ = _ensure_data(values)
0 commit comments