@@ -29,7 +29,8 @@ def date_range_frame():
29
29
30
30
class TestFrameAsof :
31
31
def test_basic (self , date_range_frame ):
32
- df = date_range_frame
32
+ # Explicitly cast to float to avoid implicit cast when setting np.nan
33
+ df = date_range_frame .astype ({"A" : "float" })
33
34
N = 50
34
35
df .loc [df .index [15 :30 ], "A" ] = np .nan
35
36
dates = date_range ("1/1/1990" , periods = N * 3 , freq = "25s" )
@@ -50,7 +51,8 @@ def test_basic(self, date_range_frame):
50
51
51
52
def test_subset (self , date_range_frame ):
52
53
N = 10
53
- df = date_range_frame .iloc [:N ].copy ()
54
+ # explicitly cast to float to avoid implicit upcast when setting to np.nan
55
+ df = date_range_frame .iloc [:N ].copy ().astype ({"A" : "float" })
54
56
df .loc [df .index [4 :8 ], "A" ] = np .nan
55
57
dates = date_range ("1/1/1990" , periods = N * 3 , freq = "25s" )
56
58
@@ -163,7 +165,7 @@ def test_time_zone_aware_index(self, stamp, expected):
163
165
def test_is_copy (self , date_range_frame ):
164
166
# GH-27357, GH-30784: ensure the result of asof is an actual copy and
165
167
# doesn't track the parent dataframe / doesn't give SettingWithCopy warnings
166
- df = date_range_frame
168
+ df = date_range_frame . astype ({ "A" : "float" })
167
169
N = 50
168
170
df .loc [df .index [15 :30 ], "A" ] = np .nan
169
171
dates = date_range ("1/1/1990" , periods = N * 3 , freq = "25s" )
0 commit comments