Skip to content

TST: series offset artithmetic tests #34582

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

Closed
wants to merge 9 commits into from
33 changes: 33 additions & 0 deletions pandas/tests/series/test_arithmetic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import timedelta
import operator
import warnings

import numpy as np
import pytest
Expand Down Expand Up @@ -679,6 +680,38 @@ def test_series_add_aware_naive_raises(self):
with pytest.raises(Exception, match=msg):
ser_utc + ser

def test_series_add_daytime_offset(self):
# GH#19211
# Ignore PerformanceWarning for this test case
warnings.simplefilter(action="ignore", category=pd.errors.PerformanceWarning)
ser_daytime = pd.Series(
[pd.Timestamp("2000-01-01"), pd.Timestamp("2000-02-01")]
)
ser_offset = pd.Series(
[pd.offsets.DateOffset(years=1), pd.offsets.DateOffset(months=2)]
)

result = ser_daytime + ser_offset

expected = pd.Series([pd.Timestamp("2001-01-01"), pd.Timestamp("2000-04-01")])
tm.assert_series_equal(result, expected)

def test_series_sub_daytime_offset(self):
# GH#19211
# Ignore PerformanceWarning for this test case
warnings.simplefilter(action="ignore", category=pd.errors.PerformanceWarning)
ser_daytime = pd.Series(
[pd.Timestamp("2000-01-01"), pd.Timestamp("2000-03-29")]
)
ser_offset = pd.Series(
[pd.offsets.DateOffset(years=1), pd.offsets.DateOffset(months=2)]
)

result = ser_daytime - ser_offset

expected = pd.Series([pd.Timestamp("1999-1-1"), pd.Timestamp("2000-1-29")])
tm.assert_series_equal(result, expected)

def test_datetime_understood(self):
# Ensures it doesn't fail to create the right series
# reported in issue#16726
Expand Down