File tree 2 files changed +31
-4
lines changed
pandas/tests/tseries/offsets
2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 7
7
8
8
import pytest
9
9
10
+ import pandas as pd
10
11
from pandas .tests .tseries .offsets .common import (
11
12
Base ,
12
13
assert_is_on_offset ,
19
20
)
20
21
21
22
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
+
22
46
class TestBMonthBegin (Base ):
23
47
_offset = BMonthBegin
24
48
Original file line number Diff line number Diff line change 1
1
"""
2
- Tests for Year, Quarter, and Month-based DateOffset subclasses
2
+ Tests for offset behavior with indices.
3
3
"""
4
4
import pytest
5
5
6
- import pandas as pd
6
+ from pandas import (
7
+ Series ,
8
+ date_range ,
9
+ )
7
10
8
11
from pandas .tseries .offsets import (
9
12
BMonthBegin ,
41
44
)
42
45
def test_apply_index (cls , n ):
43
46
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 )
46
49
47
50
res = rng + offset
48
51
assert res .freq is None # not retained
You can’t perform that action at this time.
0 commit comments