Skip to content

Commit 8846135

Browse files
committed
added test for bug which appeared in v0.24.2 but is fixed in master
1 parent 38e1b9b commit 8846135

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/groupby/test_apply.py

+14
Original file line numberDiff line numberDiff line change
@@ -901,3 +901,17 @@ def fn(x):
901901
name="col2",
902902
)
903903
tm.assert_series_equal(result, expected)
904+
905+
906+
def test_apply_reindex_values():
907+
# GH: 26209
908+
values = [1, 2, 3, 4]
909+
indices = [1, 1, 2, 2]
910+
df = pd.DataFrame(
911+
{"group": ["Group1", "Group2"] * 2, "value": values}, index=indices
912+
)
913+
srs_exp = pd.Series(values, index=indices, name="value")
914+
srs_grouped = df.groupby("group").value.apply(
915+
lambda x: x.reindex(np.arange(x.index.min(), x.index.max() + 1))
916+
)
917+
tm.assert_series_equal(srs_exp, srs_grouped)

0 commit comments

Comments
 (0)