Skip to content

Commit afc1372

Browse files
code sample for pandas-dev#46496
1 parent 9c6d7d7 commit afc1372

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

bisect/46496.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# BUG: lambda with positional references in apply after groupby on empty dataframe errors #46496
2+
3+
import pandas as pd
4+
5+
print(pd.__version__)
6+
7+
8+
result = (
9+
pd.DataFrame([], columns=["a", "b", "c"])
10+
.groupby("a")
11+
.b.apply(lambda x: x[0] - x[1])
12+
)
13+
print(repr(result))
14+
15+
expected = pd.Series(
16+
[],
17+
name="b",
18+
dtype=object,
19+
index=pd.Index([], dtype="object", name="a"),
20+
)
21+
pd.testing.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)