Skip to content

TST: GroupBy.ffill on a multi-index dataframe #55408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3245,3 +3245,16 @@ def test_get_group_axis_1():
}
)
tm.assert_frame_equal(result, expected)


def test_groupby_ffill_with_duplicated_index():
# GH#43412
df = DataFrame(
{"a": [1, 2, 3, 4, np.nan, np.nan]}, index=[0, 1, 2, 0, 1, 2], dtype=float
)

result = df.groupby(level=0).ffill()
expected = DataFrame(
{"a": [1, 2, 3, 4, 2, 3]}, index=[0, 1, 2, 0, 1, 2], dtype=float
)
tm.assert_frame_equal(result, expected)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can specify check_dtype=False here instead of needing to specify float above. i think the result should be int but can be investigated later