-
Notifications
You must be signed in to change notification settings - Fork 173
[ENH] Minor fixes #833
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
[ENH] Minor fixes #833
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #833 +/- ##
==========================================
+ Coverage 95.26% 95.34% +0.07%
==========================================
Files 19 19
Lines 1966 1975 +9
==========================================
+ Hits 1873 1883 +10
+ Misses 93 92 -1 |
expected = df.assign(s3=df.s1.combine_first(df.s2).fillna(0)) | ||
result = df.coalesce( | ||
["s1", "s2"], target_column_name="s3", default_value=0 | ||
) | ||
assert_frame_equal(result, expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much nicer expression of the test!
def test_update_where_query(): | ||
"""Test that function works with pandas query-style string expression.""" | ||
df = pd.DataFrame( | ||
@pytest.fixture | ||
def df(): | ||
return pd.DataFrame( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice refactor!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work, @samukweku! Thank you for handling these improvements. I am approving! Will let it simmer for one or two more days before we merge.
PR Description
Please describe the changes proposed in the pull request:
coalesce
returns the entire dataframe, along with a new column (iftarget_column_name
is not None)bfill(1).ffill(1)
syntax, which is faster thanreduce(combine.first)
default_value
parameter, to fill any remaining nulls.update_where
to usepd.eval
for string-like conditions.This PR resolves #831 .
PR Checklist
Please ensure that you have done the following:
<your_username>
:dev
, but rather from<your_username>
:<feature-branch_name>
.AUTHORS.rst
.CHANGELOG.md
under the latest version header (i.e. the one that is "on deck") describing the contribution.Automatic checks
There will be automatic checks run on the PR. These include:
Relevant Reviewers
Please tag maintainers to review.