1010import numpy as np
1111import pytest
1212
13- from pandas .errors import SpecificationError
13+ from pandas .errors import (
14+ Pandas4Warning ,
15+ SpecificationError ,
16+ )
1417
1518import pandas as pd
1619from pandas import (
@@ -545,21 +548,21 @@ def test_multiindex_columns_empty_level(self):
545548 grouped = df .groupby ("to filter" ).groups
546549 assert grouped ["A" ] == [0 ]
547550
548- with tm .assert_produces_warning (FutureWarning , match = msg ):
551+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
549552 grouped = df .groupby ([("to filter" , "" )]).groups
550553 assert grouped ["A" ] == [0 ]
551554
552555 df = DataFrame ([[1 , "A" ], [2 , "B" ]], columns = midx )
553556
554557 expected = df .groupby ("to filter" ).groups
555- with tm .assert_produces_warning (FutureWarning , match = msg ):
558+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
556559 result = df .groupby ([("to filter" , "" )]).groups
557560 assert result == expected
558561
559562 df = DataFrame ([[1 , "A" ], [2 , "A" ]], columns = midx )
560563
561564 expected = df .groupby ("to filter" ).groups
562- with tm .assert_produces_warning (FutureWarning , match = msg ):
565+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
563566 result = df .groupby ([("to filter" , "" )]).groups
564567 tm .assert_dict_equal (result , expected )
565568
@@ -571,7 +574,7 @@ def test_groupby_multiindex_tuple(self):
571574 )
572575
573576 msg = "`groups` by one element list returns scalar is deprecated"
574- with tm .assert_produces_warning (FutureWarning , match = msg ):
577+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
575578 expected = df .groupby ([("b" , 1 )]).groups
576579 result = df .groupby (("b" , 1 )).groups
577580 tm .assert_dict_equal (expected , result )
@@ -583,14 +586,14 @@ def test_groupby_multiindex_tuple(self):
583586 ),
584587 )
585588
586- with tm .assert_produces_warning (FutureWarning , match = msg ):
589+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
587590 expected = df2 .groupby ([("b" , "d" )]).groups
588591 result = df .groupby (("b" , 1 )).groups
589592 tm .assert_dict_equal (expected , result )
590593
591594 df3 = DataFrame (df .values , columns = [("a" , "d" ), ("b" , "d" ), ("b" , "e" ), "c" ])
592595
593- with tm .assert_produces_warning (FutureWarning , match = msg ):
596+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
594597 expected = df3 .groupby ([("b" , "d" )]).groups
595598 result = df .groupby (("b" , 1 )).groups
596599 tm .assert_dict_equal (expected , result )
@@ -623,7 +626,7 @@ def test_groupby_multiindex_partial_indexing_equivalence(self):
623626 tm .assert_frame_equal (expected_max , result_max )
624627
625628 msg = "`groups` by one element list returns scalar is deprecated"
626- with tm .assert_produces_warning (FutureWarning , match = msg ):
629+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
627630 expected_groups = df .groupby ([("a" , 1 )])[[("b" , 1 ), ("b" , 2 )]].groups
628631 result_groups = df .groupby ([("a" , 1 )])["b" ].groups
629632 tm .assert_dict_equal (expected_groups , result_groups )
@@ -737,7 +740,7 @@ def test_list_grouper_with_nat(self):
737740 # Grouper in a list grouping
738741 gb = df .groupby ([grouper ])
739742 expected = {Timestamp ("2011-01-01" ): Index (list (range (364 )))}
740- with tm .assert_produces_warning (FutureWarning , match = msg ):
743+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
741744 result = gb .groups
742745 tm .assert_dict_equal (result , expected )
743746
@@ -1019,7 +1022,7 @@ def test_groups(self, df):
10191022 grouped = df .groupby (["A" ])
10201023 msg = "`groups` by one element list returns scalar is deprecated"
10211024
1022- with tm .assert_produces_warning (FutureWarning , match = msg ):
1025+ with tm .assert_produces_warning (Pandas4Warning , match = msg ):
10231026 groups = grouped .groups
10241027 assert groups is grouped .groups # caching works
10251028
0 commit comments