Skip to content

Commit 4ba0e25

Browse files
committed
add test for former bug (appeared in 0.24.2 but fixed in further versions)
1 parent 455de19 commit 4ba0e25

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/groupby/test_apply.py

+16
Original file line numberDiff line numberDiff line change
@@ -901,3 +901,19 @@ 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,
912+
'value': values},
913+
index=indices
914+
)
915+
srs_exp = pd.Series(values, index=indices, name='value')
916+
srs_grouped = df.groupby('group').value.apply(
917+
lambda x: x.reindex(np.arange(x.index.min(), x.index.max() + 1))
918+
)
919+
tm.assert_series_equal(srs_exp, srs_grouped)

0 commit comments

Comments
 (0)