Skip to content

Commit 0bfede2

Browse files
authored
[TST]: Groupby raised error with duplicate column names (#36389)
1 parent 8ea00fb commit 0bfede2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/groupby/test_groupby.py

+11
Original file line numberDiff line numberDiff line change
@@ -2126,3 +2126,14 @@ def test_groupby_column_index_name_lost(func):
21262126
df_grouped = df.groupby([1])
21272127
result = getattr(df_grouped, func)().columns
21282128
tm.assert_index_equal(result, expected)
2129+
2130+
2131+
def test_groupby_duplicate_columns():
2132+
# GH: 31735
2133+
df = pd.DataFrame(
2134+
{"A": ["f", "e", "g", "h"], "B": ["a", "b", "c", "d"], "C": [1, 2, 3, 4]}
2135+
).astype(object)
2136+
df.columns = ["A", "B", "B"]
2137+
result = df.groupby([0, 0, 0, 0]).min()
2138+
expected = pd.DataFrame([["e", "a", 1]], columns=["A", "B", "B"])
2139+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)