-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: align with broadcast_axis, #13194 #13198
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
Changes from 6 commits
b4867df
a4e6804
51c5968
e15e17e
e6ec1d9
1b5bbde
fb1b41f
248e8da
6de9b0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -880,3 +880,53 @@ def test_reindex_multi(self): | |
expected = df.reindex([0, 1]).reindex(columns=['a', 'b']) | ||
|
||
assert_frame_equal(result, expected) | ||
|
||
def test_align_broadcast_axis(self): | ||
# GH 13194 | ||
# For 'outer' join | ||
df = DataFrame(np.array([[1., 2.], [3., 4.]]), columns=list('AB')) | ||
ts = Series([5., 6., 7.]) | ||
result = df.align(ts, join='outer', axis=0, broadcast_axis=1) | ||
result1 = DataFrame(result[0]) | ||
result2 = DataFrame(result[1]) | ||
expected1 = DataFrame(np.array([[1., 2.], [3., 4.], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. call these |
||
[pd.np.nan, pd.np.nan]]), | ||
columns=list('AB')) | ||
expected2 = DataFrame(np.array([[5., 5.], [6., 6.], [7., 7.]]), | ||
columns=list('AB')) | ||
assert_frame_equal(result1, expected1) | ||
assert_frame_equal(result2, expected2) | ||
|
||
# For 'inner' join | ||
result = df.align(ts, join='inner', axis=0, broadcast_axis=1) | ||
result1 = DataFrame(result[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed. Test returned obj ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sinhrks I'm not sure that I understand. Can you please elaborate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pls remove
|
||
result2 = DataFrame(result[1]) | ||
expected1 = DataFrame(np.array([[1., 2.], [3., 4.]]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need to pass these as numpy arrays, just list-of-lists is fine |
||
columns=list('AB')) | ||
expected2 = DataFrame(np.array([[5., 5.], [6., 6.]]), | ||
columns=list('AB')) | ||
assert_frame_equal(result1, expected1) | ||
assert_frame_equal(result2, expected2) | ||
|
||
# For 'left' join | ||
result = df.align(ts, join='left', axis=0, broadcast_axis=1) | ||
result1 = DataFrame(result[0]) | ||
result2 = DataFrame(result[1]) | ||
expected1 = DataFrame(np.array([[1., 2.], [3., 4.]]), | ||
columns=list('AB')) | ||
expected2 = DataFrame(np.array([[5., 5.], [6., 6.]]), | ||
columns=list('AB')) | ||
assert_frame_equal(result1, expected1) | ||
assert_frame_equal(result2, expected2) | ||
|
||
# For 'right' join | ||
result = df.align(ts, join='right', axis=0, broadcast_axis=1) | ||
result1 = DataFrame(result[0]) | ||
result2 = DataFrame(result[1]) | ||
expected1 = DataFrame(np.array([[1., 2.], [3., 4.], | ||
[pd.np.nan, pd.np.nan]]), | ||
columns=list('AB')) | ||
expected2 = DataFrame(np.array([[5., 5.], [6., 6.], [7., 7.]]), | ||
columns=list('AB')) | ||
assert_frame_equal(result1, expected1) | ||
assert_frame_equal(result2, expected2) |
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.
Single line of comments pls. these are read by the users and don't need this kind of explanation.