Skip to content

Commit 5117fd1

Browse files
code sample for pandas-dev#46375
1 parent afc1372 commit 5117fd1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bisect/46375.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# BUG: DataFrameGroupBy.sum() drops column names when applied to an empty dataframe #46375
2+
3+
import pandas as pd
4+
5+
print(pd.__version__)
6+
7+
df = pd.DataFrame(columns=["a", "b", "c"])
8+
result = df.groupby("a", as_index=False).sum()
9+
print(result)
10+
11+
expected = pd.Index(["a", "b", "c"], dtype="object")
12+
pd.testing.assert_index_equal(result.columns, expected)

0 commit comments

Comments
 (0)