Skip to content
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

TST: add test_ffill_with_string_column #40557

Merged
merged 8 commits into from
May 13, 2021
Merged

Conversation

shiv-io
Copy link
Contributor

@shiv-io shiv-io commented Mar 21, 2021

#40250 is an issue which seems to have been fixed in master already through #39446. This PR adds a test for this issue.

Copy link
Member

@mzeitlin11 mzeitlin11 left a comment

Choose a reason for hiding this comment

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

This LGTM @shiv-io, thanks for contributing to pandas! Is there a reason the pr is in draft status?

@shiv-io
Copy link
Contributor Author

shiv-io commented Mar 21, 2021

Hey @mzeitlin11, no reason in particular - just thought I'd wait for the CI checks to pass before making it ready for review.

It does seem that one of the CI checks is failing (CI / Web and docs), but I have no reason to suspect that the failure has to do with the changes in this PR.

Also: it seems that the whatsnew entry may not be needed since this is just testing an already-fixed bug. Let me know if that's the case.

I have marked as ready to review! Thank you

@mzeitlin11
Copy link
Member

Hey @mzeitlin11, no reason in particular - just thought I'd wait for the CI checks to pass before making it ready for review.

It does seem that one of the CI checks is failing (CI / Web and docs), but I have no reason to suspect that the failure has to do with the changes in this PR.

Also: it seems that the whatsnew entry may not be needed since this is just testing an already-fixed bug. Let me know if that's the case.

I have marked as ready to review! Thank you

Yep, whatsnew is not necessary. The CI / Web and docs failure is unrelated and should be fixed by #40542

@shiv-io shiv-io marked this pull request as ready for review March 21, 2021 18:42
@mzeitlin11 mzeitlin11 added Testing pandas testing functions or related to the test suite Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Strings String extension data type and string data labels Mar 23, 2021
def test_ffill_with_string_column():
# GH 40250
result = (
DataFrame({"a": pd.array([None, "a"], dtype="string"), "b": [0, 0]})
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 change the example so it also fills a forward value (e.g. make the input '[None, "a", None]'

.groupby("b")
.ffill()
)
expected = DataFrame({"a": pd.array([None, "a"], dtype="string")})
Copy link
Contributor

Choose a reason for hiding this comment

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

would also not object to a parameterized version which tests bfill as well.

@@ -43,6 +43,17 @@ def test_ffill_missing_arguments():
df.groupby("b").fillna()


def test_ffill_with_string_column():
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to test_ffill_with_string_dtype

Copy link
Contributor Author

@shiv-io shiv-io Apr 17, 2021

Choose a reason for hiding this comment

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

I thought it made sense to rename to test_fillna_with_string_dtype since I have now parameterized the test to test both ffill and bfill.

expected = DataFrame({"a": pd.array([None, "a"], dtype="string")})
tm.assert_frame_equal(result, expected)


Copy link
Contributor

Choose a reason for hiding this comment

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

we may have a similar example with object dtype, if you can co-locate, alternatively can parameterize on the dtype as well.

Copy link
Member

Choose a reason for hiding this comment

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

after #41343 is merged, can use the any_string_dtype fixture

@shiv-io shiv-io requested a review from jreback April 17, 2021 11:49
@simonjayhawkins simonjayhawkins added this to the 1.3 milestone May 9, 2021
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @shiv-io lgtm pending green (param on any_string_dtype could be a follow-up)

@jreback jreback merged commit 5410f2d into pandas-dev:master May 13, 2021
@jreback
Copy link
Contributor

jreback commented May 13, 2021

thanks @shiv-io

JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Strings String extension data type and string data Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: ValueError when calling groupby + fillna on StringDType column
4 participants