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
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
test for date comparison
  • Loading branch information
jbrockmendel committed Feb 22, 2018
commit db487e8ba5f8efcdae8c949e70d0bca188c3d44e
16 changes: 16 additions & 0 deletions pandas/tests/series/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ def test_ser_cmp_result_names(self, names, op):


class TestTimestampSeriesComparison(object):
def test_dt64ser_cmp_date_invalid(self):
# GH#19800 datetime.date comparison raises to
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we had a reference to the python docs about this, can you add it here. IOW a future reader may not know this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see this mentioned here. Is there another doc you have in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't recall, but this is a 'feature' in Python. Need a reference to it. For the next reader.

# match DatetimeIndex/Timestamp/datetime
ser = pd.Series(pd.date_range('20010101', periods=10), name='dates')
date = ser.iloc[0].to_pydatetime().date()
assert not (ser == date).any()
assert (ser != date).all()
with pytest.raises(TypeError):
ser > date
with pytest.raises(TypeError):
ser < date
with pytest.raises(TypeError):
ser >= date
with pytest.raises(TypeError):
ser <= date

def test_dt64ser_cmp_period_scalar(self):
ser = Series(pd.period_range('2000-01-01', periods=10, freq='D'))
val = Period('2000-01-04', freq='D')
Expand Down
0