@@ -426,24 +426,12 @@ def test_dataframe_groupby_getitem_error(
426426 scalars_pandas_df_index ,
427427):
428428 col_names = ["float64_col" , "int64_col" , "bool_col" , "string_col" ]
429- with pytest .raises (KeyError , match = "\" Columns not found: 'not_in_group'\" " ):
430- (
431- scalars_df_index [col_names ]
432- .groupby ("string_col" )["not_in_group" ]
433- .min ()
434- .to_pandas ()
435- )
436-
437-
438- def test_dataframe_groupby_getitem_multiple_columns_error (
439- scalars_df_index ,
440- scalars_pandas_df_index ,
441- ):
442- col_names = ["float64_col" , "int64_col" , "bool_col" , "string_col" ]
443- with pytest .raises (KeyError , match = "\" Columns not found: 'col1', 'col2'\" " ):
429+ with pytest .raises (
430+ KeyError , match = r"Columns not found: 'not_in_group'. Did you mean 'string_col'?"
431+ ):
444432 (
445433 scalars_df_index [col_names ]
446- .groupby ("string_col " )["col1" , "col2 " ]
434+ .groupby ("bool_col " )["not_in_group " ]
447435 .min ()
448436 .to_pandas ()
449437 )
@@ -464,6 +452,23 @@ def test_dataframe_groupby_getitem_list(
464452 pd .testing .assert_frame_equal (pd_result , bf_result , check_dtype = False )
465453
466454
455+ def test_dataframe_groupby_getitem_list_error (
456+ scalars_df_index ,
457+ scalars_pandas_df_index ,
458+ ):
459+ col_names = ["float64_col" , "int64_col" , "bool_col" , "string_col" ]
460+ with pytest .raises (
461+ KeyError ,
462+ match = r"Columns not found: 'col1', 'float'. Did you mean 'bool_col', 'float64_col'?" ,
463+ ):
464+ (
465+ scalars_df_index [col_names ]
466+ .groupby ("string_col" )["col1" , "float" ]
467+ .min ()
468+ .to_pandas ()
469+ )
470+
471+
467472def test_dataframe_groupby_nonnumeric_with_mean ():
468473 df = pd .DataFrame (
469474 {
0 commit comments