Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: Fix regression in datetime ops #17980

Merged
merged 3 commits into from
Oct 26, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ def _is_offset(self, arr_or_obj):
""" check if obj or all elements of list-like is DateOffset """
if isinstance(arr_or_obj, ABCDateOffset):
return True
elif (is_datetime64_dtype(arr_or_obj) or
is_timedelta64_dtype(arr_or_obj)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catch period here as well?

Copy link
Contributor Author

@TomAugspurger TomAugspurger Oct 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What binary ops is a PeriodIndex valid in (if any)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_period

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, we have is_period_dtype which is the correct to use here

# Don't want to check elementwise for Series / array of datetime
return False
elif is_list_like(arr_or_obj) and len(arr_or_obj):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you actually only do this check if is_object_dtype is True in the first place, otherwise no point in iterating at all (if its not a scalar ABCDateOffset)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think d0ea5dc has want you meant, much cleaner.

return all(isinstance(x, ABCDateOffset) for x in arr_or_obj)
return False
Expand Down