Skip to content

Commit 0801c8d

Browse files
committed
TST: ensure groupby get by index value #33439
1 parent 8aa7072 commit 0801c8d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/groupby/aggregate/test_aggregate.py

+8
Original file line numberDiff line numberDiff line change
@@ -940,3 +940,11 @@ def test_agg_multiple_lambda(self):
940940
weight_min=pd.NamedAgg(column="weight", aggfunc=lambda x: np.min(x)),
941941
)
942942
tm.assert_frame_equal(result2, expected)
943+
944+
945+
def test_groupby_get_by_index():
946+
# GH 33439
947+
df = pd.DataFrame({"A": ["S", "W", "W"], "B": [1.0, 1.0, 2.0]})
948+
res = df.groupby("A").agg({"B": lambda x: x.get(x.index[-1])})
949+
expected = pd.DataFrame(dict(A=["S", "W"], B=[1.0, 2.0])).set_index("A")
950+
pd.testing.assert_frame_equal(res, expected)

0 commit comments

Comments
 (0)