Skip to content

API: transform behaves differently with 'ffill' on DataFrameGroupBy and SeriesGroupBy #39638

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 4 commits into from
Feb 15, 2021
Merged
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions pandas/tests/groupby/transform/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,16 @@ def test_any_all_np_func(func):
tm.assert_series_equal(res, exp)


def test_transform_ffill():
# GH 24211
data = [["a", 0.0], ["a", float("nan")], ["b", 1.0], ["b", float("nan")]]
Copy link
Contributor

Choose a reason for hiding this comment

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

can you co-locate with other ffill/filling tests (in this file)

df = DataFrame(data, columns=["key", "values"])
tm.assert_series_equal(
df.groupby("key").transform("ffill")["values"],
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use
result=
expected=

df.groupby("key")["values"].transform("ffill"),
)

Copy link
Contributor

Choose a reason for hiding this comment

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

test both for seriesgropuby & dataframegroupby


def test_groupby_transform_rename():
# https://github.com/pandas-dev/pandas/issues/23461
def demean_rename(x):
Expand Down