Skip to content

Commit 83e99cf

Browse files
committed
PERF: Fix regression in datetime ops
HEAD: ``` In [1]: import pandas as pd; import numpy as np In [2]: s = pd.Series(pd.to_datetime(np.arange(100000), unit='ms')) In [3]: %timeit s - s.shift() 2.73 ms ± 30.1 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) ``` 0.21.0rc1: ``` 527 ms ± 11.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) ``` 0.20.3 ``` 2.4 ms ± 57.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) ```
1 parent 36c309e commit 83e99cf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pandas/core/ops.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,9 @@ def _is_offset(self, arr_or_obj):
622622
""" check if obj or all elements of list-like is DateOffset """
623623
if isinstance(arr_or_obj, ABCDateOffset):
624624
return True
625+
elif is_datetime64_dtype(arr_or_obj):
626+
# Don't want to check elementwise for Series / array of datetime
627+
return False
625628
elif is_list_like(arr_or_obj) and len(arr_or_obj):
626629
return all(isinstance(x, ABCDateOffset) for x in arr_or_obj)
627630
return False

0 commit comments

Comments
 (0)