Skip to content

Commit 0319a32

Browse files
committed
Fix tests
1 parent ba11c0b commit 0319a32

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

pandas/tests/groupby/test_groupby.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ def f(x, q=None, axis=0):
116116
expected_seq = df_grouped.quantile([0.4, 0.8])
117117
if not as_index:
118118
# apply treats the op as a transform; .quantile knows it's a reduction
119-
apply_result = apply_result.reset_index()
120-
apply_result["level_0"] = [1, 1, 2, 2]
119+
apply_result.index = range(4)
120+
apply_result.insert(loc=0, column="level_0", value=[1, 1, 2, 2])
121+
apply_result.insert(loc=1, column="level_1", value=[0.4, 0.8, 0.4, 0.8])
121122
tm.assert_frame_equal(apply_result, expected_seq, check_names=False)
122123

123124
agg_result = df_grouped.agg(f, q=80)
@@ -522,13 +523,7 @@ def test_as_index_select_column():
522523
result = df.groupby("A", as_index=False, group_keys=True)["B"].apply(
523524
lambda x: x.cumsum()
524525
)
525-
expected = Series(
526-
[2, 6, 6],
527-
name="B",
528-
index=MultiIndex(
529-
levels=[RangeIndex(2), RangeIndex(3)], codes=[[0, 0, 1], [0, 1, 2]]
530-
),
531-
)
526+
expected = Series([2, 6, 6], name="B", index=range(3))
532527
tm.assert_series_equal(result, expected)
533528

534529

0 commit comments

Comments
 (0)