diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 8a261f09e7118..f1a8a70674582 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -973,7 +973,7 @@ def _aggregate_frame(self, func, *args, **kwargs) -> DataFrame: result: dict[Hashable, NDFrame | np.ndarray] = {} if self.axis == 0: # test_pass_args_kwargs_duplicate_columns gets here with non-unique columns - for name, data in self: + for name, data in self.grouper.get_iterator(obj, self.axis): fres = func(data, *args, **kwargs) result[name] = fres else: diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 138474e21fb57..67f645c008ac3 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -828,7 +828,7 @@ def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]: ( "In a future version of pandas, a length 1 " "tuple will be returned when iterating over a " - "a groupby with a grouper equal to a list of " + "groupby with a grouper equal to a list of " "length 1. Don't supply a list with a single grouper " "to avoid this warning." ), diff --git a/pandas/tests/groupby/aggregate/test_numba.py b/pandas/tests/groupby/aggregate/test_numba.py index 2890b7930611c..0b2fb56a02006 100644 --- a/pandas/tests/groupby/aggregate/test_numba.py +++ b/pandas/tests/groupby/aggregate/test_numba.py @@ -214,6 +214,7 @@ def func_kwargs(values, index): @td.skip_if_no("numba") +@pytest.mark.filterwarnings("ignore") def test_multiindex_one_key(nogil, parallel, nopython): def numba_func(values, index): return 1 diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index d290aada18293..a63e0df25b160 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -2801,7 +2801,7 @@ def test_single_element_list_grouping(): ) msg = ( "In a future version of pandas, a length 1 " - "tuple will be returned when iterating over a " + "tuple will be returned when iterating over " "a groupby with a grouper equal to a list of " "length 1. Don't supply a list with a single grouper " "to avoid this warning." diff --git a/pandas/tests/groupby/transform/test_numba.py b/pandas/tests/groupby/transform/test_numba.py index 0e26cdc294b55..2b70d7325a209 100644 --- a/pandas/tests/groupby/transform/test_numba.py +++ b/pandas/tests/groupby/transform/test_numba.py @@ -202,6 +202,7 @@ def func_kwargs(values, index): @td.skip_if_no("numba") +@pytest.mark.filterwarnings("ignore") def test_multiindex_one_key(nogil, parallel, nopython): def numba_func(values, index): return 1 diff --git a/pandas/tests/io/excel/test_readers.py b/pandas/tests/io/excel/test_readers.py index 4ca34bec0a7d9..fa1d6bbfd5a7e 100644 --- a/pandas/tests/io/excel/test_readers.py +++ b/pandas/tests/io/excel/test_readers.py @@ -89,6 +89,7 @@ def _transfer_marks(engine, read_ext): for ext in read_ext_params if _is_valid_engine_ext_pair(eng, ext) ], + ids=str, ) def engine_and_read_ext(request): """ @@ -654,6 +655,7 @@ def test_read_excel_blank_with_header(self, read_ext): actual = pd.read_excel("blank_with_header" + read_ext, sheet_name="Sheet1") tm.assert_frame_equal(actual, expected) + @pytest.mark.filterwarnings("ignore:Cell A4 is marked:UserWarning:openpyxl") def test_date_conversion_overflow(self, request, engine, read_ext): # GH 10001 : pandas.ExcelFile ignore parse_dates=False if engine == "pyxlsb": diff --git a/pandas/tests/io/excel/test_writers.py b/pandas/tests/io/excel/test_writers.py index ba6366b71d854..977f278b7d04c 100644 --- a/pandas/tests/io/excel/test_writers.py +++ b/pandas/tests/io/excel/test_writers.py @@ -878,7 +878,7 @@ def test_to_excel_output_encoding(self, ext): ) with tm.ensure_clean("__tmp_to_excel_float_format__." + ext) as filename: - df.to_excel(filename, sheet_name="TestSheet", encoding="utf8") + df.to_excel(filename, sheet_name="TestSheet") result = pd.read_excel(filename, sheet_name="TestSheet", index_col=0) tm.assert_frame_equal(result, df) @@ -1282,6 +1282,7 @@ def test_deprecated_attr(self, engine, ext, attr): # Some engines raise if nothing is written DataFrame().to_excel(writer) + @pytest.mark.filterwarnings("ignore:Calling close():UserWarning:xlsxwriter") @pytest.mark.parametrize( "attr, args", [("save", ()), ("write_cells", ([], "test"))] ) diff --git a/pandas/tests/reshape/merge/test_join.py b/pandas/tests/reshape/merge/test_join.py index d97c6a3dacdc3..6e87c221426c1 100644 --- a/pandas/tests/reshape/merge/test_join.py +++ b/pandas/tests/reshape/merge/test_join.py @@ -737,7 +737,9 @@ def _check_join(left, right, result, join_col, how="left", lsuffix="_x", rsuffix left_grouped = left.groupby(join_col) right_grouped = right.groupby(join_col) - for group_key, group in result.groupby(join_col): + for group_key, group in result.groupby( + join_col if len(join_col) > 1 else join_col[0] + ): l_joined = _restrict_to_columns(group, left.columns, lsuffix) r_joined = _restrict_to_columns(group, right.columns, rsuffix)