8000 dispatch Series[datetime64] comparison ops to DatetimeIndex by jbrockmendel · Pull Request #19800 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

dispatch Series[datetime64] comparison ops to DatetimeIndex #19800

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

Merged
merged 16 commits into from
Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
comments
  • Loading branch information
jbrockmendel committed Feb 24, 2018
commit f8d5bddabdce0d90ef10ddfa9de1013138a4ceff
2 changes: 2 additions & 0 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def wrapper(self, other):
result = func(np.asarray(other))
result = com._values_from_object(result)

# Make sure to pass an array to result[...]; indexing with
# Series breaks with older version of numpy
o_mask = np.array(isna(other))
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need the np.array?

Copy link
Member Author

Choose a reason for hiding this comment

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

Test failures with older versions of numpy when o_mask is a Series.

Copy link
Contributor
@jreback jreback Feb 24, 2018

Choose a reason for hiding this comment

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

grr. ok, use np.asarray though

if o_mask.any():
result[o_mask] = nat_result
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ def wrapper(self, other, axis=None):
name=res_name)

Copy link
Contributor

Choose a reason for hiding this comment

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

can you add some comments at various places

if is_datetime64_dtype(self) or is_datetime64tz_dtype(self):
# Dispatch to DatetimeIndex to ensure identical
# Series/Index behavior
res_values = dispatch_to_index_op(op, self, other,
pd.DatetimeIndex)
return self._constructor(res_values, index=self.index,
Expand Down
0