1
- import warnings
2
-
3
1
import numpy as np
4
2
import pytest
5
3
@@ -26,18 +24,15 @@ def test_basic(self, date_range_frame):
26
24
df .loc [15 :30 , "A" ] = np .nan
27
25
dates = date_range ("1/1/1990" , periods = N * 3 , freq = "25s" )
28
26
29
- with warnings .catch_warnings ():
30
- warnings .simplefilter ("ignore" , FutureWarning )
31
-
32
- result = df .asof (dates )
33
- assert result .notna ().all (1 ).all ()
34
- lb = df .index [14 ]
35
- ub = df .index [30 ]
27
+ result = df .asof (dates )
28
+ assert result .notna ().all (1 ).all ()
29
+ lb = df .index [14 ]
30
+ ub = df .index [30 ]
36
31
37
- dates = list (dates )
32
+ dates = list (dates )
38
33
39
- result = df .asof (dates )
40
- assert result .notna ().all (1 ).all ()
34
+ result = df .asof (dates )
35
+ assert result .notna ().all (1 ).all ()
41
36
42
37
mask = (result .index >= lb ) & (result .index < ub )
43
38
rs = result [mask ]
@@ -49,46 +44,41 @@ def test_subset(self, date_range_frame):
49
44
df .loc [4 :8 , "A" ] = np .nan
50
45
dates = date_range ("1/1/1990" , periods = N * 3 , freq = "25s" )
51
46
52
- with warnings .catch_warnings ():
53
- warnings .simplefilter ("ignore" , FutureWarning )
54
-
55
- # with a subset of A should be the same
56
- result = df .asof (dates , subset = "A" )
57
- expected = df .asof (dates )
58
- tm .assert_frame_equal (result , expected )
47
+ # with a subset of A should be the same
48
+ result = df .asof (dates , subset = "A" )
49
+ expected = df .asof (dates )
50
+ tm .assert_frame_equal (result , expected )
59
51
60
- # same with A/B
61
- result = df .asof (dates , subset = ["A" , "B" ])
62
- expected = df .asof (dates )
63
- tm .assert_frame_equal (result , expected )
52
+ # same with A/B
53
+ result = df .asof (dates , subset = ["A" , "B" ])
54
+ expected = df .asof (dates )
55
+ tm .assert_frame_equal (result , expected )
64
56
65
- # B gives df.asof
66
- result = df .asof (dates , subset = "B" )
67
- expected = df .resample ("25s" , closed = "right" ).ffill ().reindex (dates )
68
- expected .iloc [20 :] = 9
57
+ # B gives df.asof
58
+ result = df .asof (dates , subset = "B" )
59
+ expected = df .resample ("25s" , closed = "right" ).ffill ().reindex (dates )
60
+ expected .iloc [20 :] = 9
69
61
70
- tm .assert_frame_equal (result , expected )
62
+ tm .assert_frame_equal (result , expected )
71
63
72
64
def test_missing (self , date_range_frame ):
73
65
# GH 15118
74
66
# no match found - `where` value before earliest date in index
75
67
N = 10
76
68
df = date_range_frame .iloc [:N ].copy ()
77
- with warnings .catch_warnings ():
78
- warnings .simplefilter ("ignore" , FutureWarning )
79
69
80
- result = df .asof ("1989-12-31" )
70
+ result = df .asof ("1989-12-31" )
81
71
82
- expected = Series (
83
- index = ["A" , "B" ], name = Timestamp ("1989-12-31" ), dtype = np .float64
84
- )
85
- tm .assert_series_equal (result , expected )
72
+ expected = Series (
73
+ index = ["A" , "B" ], name = Timestamp ("1989-12-31" ), dtype = np .float64
74
+ )
75
+ tm .assert_series_equal (result , expected )
86
76
87
- result = df .asof (to_datetime (["1989-12-31" ]))
88
- expected = DataFrame (
89
- index = to_datetime (["1989-12-31" ]), columns = ["A" , "B" ], dtype = "float64"
90
- )
91
- tm .assert_frame_equal (result , expected )
77
+ result = df .asof (to_datetime (["1989-12-31" ]))
78
+ expected = DataFrame (
79
+ index = to_datetime (["1989-12-31" ]), columns = ["A" , "B" ], dtype = "float64"
80
+ )
81
+ tm .assert_frame_equal (result , expected )
92
82
93
83
def test_all_nans (self , date_range_frame ):
94
84
# GH 15713
@@ -144,8 +134,6 @@ def test_time_zone_aware_index(self, stamp, expected):
144
134
Timestamp ("2018-01-01 22:35:10.550+00:00" ),
145
135
],
146
136
)
147
- with warnings .catch_warnings ():
148
- warnings .simplefilter ("ignore" , FutureWarning )
149
137
150
- result = df .asof (stamp )
151
- tm .assert_series_equal (result , expected )
138
+ result = df .asof (stamp )
139
+ tm .assert_series_equal (result , expected )
0 commit comments