Skip to content

Commit 9a1b652

Browse files
code sample for pandas-dev#45315
1 parent 9751092 commit 9a1b652

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bisect/45315.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Behavior change of 1.4.rc0 when group by apply returns a copy of the passed data frame #45315
2+
3+
import pandas as pd
4+
5+
print(pd.__version__)
6+
7+
df = pd.DataFrame([[1, 2, 3, 4]], columns=["A", "B", "C", "D"])
8+
grouped = df.groupby(["A", "B"], as_index=True)[["C", "D"]]
9+
10+
combined = grouped.apply(lambda x: x.copy())
11+
print(combined)
12+
13+
result = combined.reset_index().columns
14+
print(result)
15+
16+
expected = pd.Index(["A", "B", "level_2", "C", "D"], dtype="object")
17+
pd.testing.assert_index_equal(result, expected)

0 commit comments

Comments
 (0)