@@ -492,3 +492,46 @@ def test_flags_identity(self, frame_or_series):
492492 assert obj .flags is obj .flags
493493 obj2 = obj .copy ()
494494 assert obj2 .flags is not obj .flags
495+
496+
497+ def test_get_cleaned_column_resolvers_robustness ():
498+ """Test _get_cleaned_column_resolvers handles edge cases.
499+ GH#62998
500+ """
501+ df = DataFrame ({"A" : [1 , 2 , 3 ], "B" : ["x" , "y" , "z" ]})
502+
503+ # The main test is that this doesn't raise an exception
504+ # with multiline dtype string representations
505+ resolvers = df ._get_cleaned_column_resolvers ()
506+
507+ # Basic validation - the method should execute without errors
508+ assert isinstance (resolvers , dict )
509+ assert len (resolvers ) == len (df .columns )
510+
511+ # Verify each resolver is a Series with correct properties
512+ for series in resolvers .values ():
513+ assert isinstance (series , Series )
514+ assert len (series ) == len (df )
515+
516+
517+ def test_query_multiline_dtype_regression ():
518+ """Regression test for the original query issue with multiline dtype strings.
519+
520+ GH#62998
521+ """
522+ # Test the exact scenario from the original issue
523+ df = DataFrame (
524+ {
525+ "Country" : ["Abkhazia" , "Afghanistan" , "Albania" , "Algeria" ],
526+ "GDP" : [1.0 , 2.0 , 3.0 , 4.0 ],
527+ }
528+ )
529+
530+ filter_list = ["Afghanistan" , "Albania" , "Algeria" ]
531+
532+ # This should not raise TypeError about dtype string representation
533+ result = df .query ("Country in @filter_list" )
534+
535+ # Verify the result is correct
536+ expected = df [df ["Country" ].isin (filter_list )]
537+ tm .assert_frame_equal (result , expected )
0 commit comments