@@ -363,7 +363,8 @@ def test_filter_and_transform_with_non_unique_int_index():
363
363
tm .assert_frame_equal (actual , expected )
364
364
365
365
actual = grouped_df .filter (lambda x : len (x ) > 1 , dropna = False )
366
- expected = df .copy ()
366
+ # Cast to avoid upcast when setting nan below
367
+ expected = df .copy ().astype ("float64" )
367
368
expected .iloc [[0 , 3 , 5 , 6 ]] = np .nan
368
369
tm .assert_frame_equal (actual , expected )
369
370
@@ -405,7 +406,8 @@ def test_filter_and_transform_with_multiple_non_unique_int_index():
405
406
tm .assert_frame_equal (actual , expected )
406
407
407
408
actual = grouped_df .filter (lambda x : len (x ) > 1 , dropna = False )
408
- expected = df .copy ()
409
+ # Cast to avoid upcast when setting nan below
410
+ expected = df .copy ().astype ("float64" )
409
411
expected .iloc [[0 , 3 , 5 , 6 ]] = np .nan
410
412
tm .assert_frame_equal (actual , expected )
411
413
@@ -447,7 +449,8 @@ def test_filter_and_transform_with_non_unique_float_index():
447
449
tm .assert_frame_equal (actual , expected )
448
450
449
451
actual = grouped_df .filter (lambda x : len (x ) > 1 , dropna = False )
450
- expected = df .copy ()
452
+ # Cast to avoid upcast when setting nan below
453
+ expected = df .copy ().astype ("float64" )
451
454
expected .iloc [[0 , 3 , 5 , 6 ]] = np .nan
452
455
tm .assert_frame_equal (actual , expected )
453
456
@@ -492,7 +495,8 @@ def test_filter_and_transform_with_non_unique_timestamp_index():
492
495
tm .assert_frame_equal (actual , expected )
493
496
494
497
actual = grouped_df .filter (lambda x : len (x ) > 1 , dropna = False )
495
- expected = df .copy ()
498
+ # Cast to avoid upcast when setting nan below
499
+ expected = df .copy ().astype ("float64" )
496
500
expected .iloc [[0 , 3 , 5 , 6 ]] = np .nan
497
501
tm .assert_frame_equal (actual , expected )
498
502
@@ -534,7 +538,8 @@ def test_filter_and_transform_with_non_unique_string_index():
534
538
tm .assert_frame_equal (actual , expected )
535
539
536
540
actual = grouped_df .filter (lambda x : len (x ) > 1 , dropna = False )
537
- expected = df .copy ()
541
+ # Cast to avoid upcast when setting nan below
542
+ expected = df .copy ().astype ("float64" )
538
543
expected .iloc [[0 , 3 , 5 , 6 ]] = np .nan
539
544
tm .assert_frame_equal (actual , expected )
540
545
0 commit comments