Skip to content

Commit 8c2d327

Browse files
authored
TST: Address test warnings (#48075)
1 parent 37fa846 commit 8c2d327

File tree

8 files changed

+12
-5
lines changed

8 files changed

+12
-5
lines changed

pandas/core/groupby/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ def _aggregate_frame(self, func, *args, **kwargs) -> DataFrame:
973973
result: dict[Hashable, NDFrame | np.ndarray] = {}
974974
if self.axis == 0:
975975
# test_pass_args_kwargs_duplicate_columns gets here with non-unique columns
976-
for name, data in self:
976+
for name, data in self.grouper.get_iterator(obj, self.axis):
977977
fres = func(data, *args, **kwargs)
978978
result[name] = fres
979979
else:

pandas/core/groupby/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]:
828828
(
829829
"In a future version of pandas, a length 1 "
830830
"tuple will be returned when iterating over a "
831-
"a groupby with a grouper equal to a list of "
831+
"groupby with a grouper equal to a list of "
832832
"length 1. Don't supply a list with a single grouper "
833833
"to avoid this warning."
834834
),

pandas/tests/groupby/aggregate/test_numba.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def func_kwargs(values, index):
214214

215215

216216
@td.skip_if_no("numba")
217+
@pytest.mark.filterwarnings("ignore")
217218
def test_multiindex_one_key(nogil, parallel, nopython):
218219
def numba_func(values, index):
219220
return 1

pandas/tests/groupby/test_groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,7 @@ def test_single_element_list_grouping():
28372837
)
28382838
msg = (
28392839
"In a future version of pandas, a length 1 "
2840-
"tuple will be returned when iterating over a "
2840+
"tuple will be returned when iterating over "
28412841
"a groupby with a grouper equal to a list of "
28422842
"length 1. Don't supply a list with a single grouper "
28432843
"to avoid this warning."

pandas/tests/groupby/transform/test_numba.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def func_kwargs(values, index):
202202

203203

204204
@td.skip_if_no("numba")
205+
@pytest.mark.filterwarnings("ignore")
205206
def test_multiindex_one_key(nogil, parallel, nopython):
206207
def numba_func(values, index):
207208
return 1

pandas/tests/io/excel/test_readers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def _transfer_marks(engine, read_ext):
8989
for ext in read_ext_params
9090
if _is_valid_engine_ext_pair(eng, ext)
9191
],
92+
ids=str,
9293
)
9394
def engine_and_read_ext(request):
9495
"""
@@ -654,6 +655,7 @@ def test_read_excel_blank_with_header(self, read_ext):
654655
actual = pd.read_excel("blank_with_header" + read_ext, sheet_name="Sheet1")
655656
tm.assert_frame_equal(actual, expected)
656657

658+
@pytest.mark.filterwarnings("ignore:Cell A4 is marked:UserWarning:openpyxl")
657659
def test_date_conversion_overflow(self, request, engine, read_ext):
658660
# GH 10001 : pandas.ExcelFile ignore parse_dates=False
659661
if engine == "pyxlsb":

pandas/tests/io/excel/test_writers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ def test_to_excel_output_encoding(self, ext):
875875
)
876876

877877
with tm.ensure_clean("__tmp_to_excel_float_format__." + ext) as filename:
878-
df.to_excel(filename, sheet_name="TestSheet", encoding="utf8")
878+
df.to_excel(filename, sheet_name="TestSheet")
879879
result = pd.read_excel(filename, sheet_name="TestSheet", index_col=0)
880880
tm.assert_frame_equal(result, df)
881881

@@ -1287,6 +1287,7 @@ def test_deprecated_attr(self, engine, ext, attr):
12871287
# Some engines raise if nothing is written
12881288
DataFrame().to_excel(writer)
12891289

1290+
@pytest.mark.filterwarnings("ignore:Calling close():UserWarning:xlsxwriter")
12901291
@pytest.mark.parametrize(
12911292
"attr, args", [("save", ()), ("write_cells", ([], "test"))]
12921293
)

pandas/tests/reshape/merge/test_join.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,9 @@ def _check_join(left, right, result, join_col, how="left", lsuffix="_x", rsuffix
737737
left_grouped = left.groupby(join_col)
738738
right_grouped = right.groupby(join_col)
739739

740-
for group_key, group in result.groupby(join_col):
740+
for group_key, group in result.groupby(
741+
join_col if len(join_col) > 1 else join_col[0]
742+
):
741743
l_joined = _restrict_to_columns(group, left.columns, lsuffix)
742744
r_joined = _restrict_to_columns(group, right.columns, rsuffix)
743745

0 commit comments

Comments
 (0)