File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
pandas/tests/tseries/offsets Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 77
88import pytest
99
10+ import pandas as pd
1011from pandas .tests .tseries .offsets .common import (
1112 Base ,
1213 assert_is_on_offset ,
1920)
2021
2122
23+ @pytest .mark .parametrize ("n" , [- 2 , 1 ])
24+ @pytest .mark .parametrize (
25+ "cls" ,
26+ [
27+ BMonthBegin ,
28+ BMonthEnd ,
29+ ],
30+ )
31+ def test_apply_index (cls , n ):
32+ offset = cls (n = n )
33+ rng = pd .date_range (start = "1/1/2000" , periods = 100000 , freq = "T" )
34+ ser = pd .Series (rng )
35+
36+ res = rng + offset
37+ assert res .freq is None # not retained
38+ assert res [0 ] == rng [0 ] + offset
39+ assert res [- 1 ] == rng [- 1 ] + offset
40+ res2 = ser + offset
41+ # apply_index is only for indexes, not series, so no res2_v2
42+ assert res2 .iloc [0 ] == ser .iloc [0 ] + offset
43+ assert res2 .iloc [- 1 ] == ser .iloc [- 1 ] + offset
44+
45+
2246class TestBMonthBegin (Base ):
2347 _offset = BMonthBegin
2448
Original file line number Diff line number Diff line change 11"""
2- Tests for Year, Quarter, and Month-based DateOffset subclasses
2+ Tests for offset behavior with indices.
33"""
44import pytest
55
6- import pandas as pd
6+ from pandas import (
7+ Series ,
8+ date_range ,
9+ )
710
811from pandas .tseries .offsets import (
912 BMonthBegin ,
4144)
4245def test_apply_index (cls , n ):
4346 offset = cls (n = n )
44- rng = pd . date_range (start = "1/1/2000" , periods = 100000 , freq = "T" )
45- ser = pd . Series (rng )
47+ rng = date_range (start = "1/1/2000" , periods = 100000 , freq = "T" )
48+ ser = Series (rng )
4649
4750 res = rng + offset
4851 assert res .freq is None # not retained
You can’t perform that action at this time.
0 commit comments