-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: support "fill_value" for ".unstack()" called with list of levels #17887
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
Conversation
65171d9
to
2d56672
Compare
Codecov Report
@@ Coverage Diff @@
## master #17887 +/- ##
==========================================
- Coverage 91.23% 91.21% -0.02%
==========================================
Files 163 163
Lines 50102 50102
==========================================
- Hits 45712 45703 -9
- Misses 4390 4399 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17887 +/- ##
==========================================
+ Coverage 91.23% 91.24% +<.01%
==========================================
Files 163 163
Lines 50105 50105
==========================================
+ Hits 45714 45718 +4
+ Misses 4391 4387 -4
Continue to review full report at Codecov.
|
pandas/tests/frame/test_reshape.py
Outdated
expected = unstacked[key] | ||
result = pd.Series([0, 0, 2], index=unstacked.index, name=key) | ||
assert_series_equal(result, expected) | ||
stacked = unstacked.stack(['x', 'y']) |
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.
put blank lines between cases
pandas/tests/frame/test_reshape.py
Outdated
assert_series_equal(result, expected) | ||
stacked = unstacked.stack(['x', 'y']) | ||
stacked.index = stacked.index.reorder_levels(f.index.names) | ||
# Workaround for GH #17886: |
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.
add a comment here on why (in addition to the issue number)
pandas/tests/frame/test_reshape.py
Outdated
@@ -154,6 +154,29 @@ def test_unstack_fill(self): | |||
index=['x', 'y', 'z'], dtype=np.float) | |||
assert_frame_equal(result, expected) | |||
|
|||
# GH #13971: fill_value when unstacking multiple levels: | |||
f = DataFrame({'x': ['a', 'a', 'b'], |
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.
we usually call this df.
lgtm minor comments. |
thanks @toobaz |
git diff upstream/master -u -- "*.py" | flake8 --diff
Notice this is a simple fix which doesn't make @kordek 's more general comment about the opportunity for refactoring less valid.