-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Switched shapes in ValueError msg in DataFrame construct (#20742) #24725
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
92b0bb3
46d4d55
aa3c5d5
35acafd
cdeeacc
31cf4f6
39b8ca9
244621b
4cfae58
7a6cd18
cb282dc
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 |
---|---|---|
|
@@ -1673,8 +1673,10 @@ def create_block_manager_from_arrays(arrays, names, axes): | |
|
||
def construction_error(tot_items, block_shape, axes, e=None): | ||
""" raise a helpful message about our construction """ | ||
passed = tuple(map(int, [tot_items] + list(block_shape))) | ||
implied = tuple(map(int, [len(ax) for ax in axes])) | ||
passed = tuple(map(int, list(block_shape) + [tot_items])) | ||
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. just do a reverse if ndim == 2 here 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. Probably not a good idea for panels with 3 dimensions (items, major, minor) The current version is the intended behavior, right? 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. I don't care about Panels, they are being removed shortly. 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. this only affect ndim==2 |
||
|
||
implied = () if len(axes) == 0 \ | ||
else tuple(len(ax) for ax in axes[1:] + [axes[0]]) | ||
if passed == implied and e is not None: | ||
raise e | ||
if block_shape[0] == 0: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1143,20 +1143,20 @@ def test_from_dict_mixed_orient(self): | |
assert panel['A'].values.dtype == np.float64 | ||
|
||
def test_constructor_error_msgs(self): | ||
msg = (r"Shape of passed values is \(3, 4, 5\), " | ||
r"indices imply \(4, 5, 5\)") | ||
msg = (r"Shape of passed values is \(4, 5, 3\), " | ||
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. leave panel entirely. |
||
r"indices imply \(5, 5, 4\)") | ||
with pytest.raises(ValueError, match=msg): | ||
Panel(np.random.randn(3, 4, 5), | ||
lrange(4), lrange(5), lrange(5)) | ||
|
||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
msg = (r"Shape of passed values is \(3, 4, 5\), " | ||
r"indices imply \(5, 4, 5\)") | ||
msg = (r"Shape of passed values is \(4, 5, 3\), " | ||
r"indices imply \(4, 5, 5\)") | ||
with pytest.raises(ValueError, match=msg): | ||
Panel(np.random.randn(3, 4, 5), | ||
lrange(5), lrange(4), lrange(5)) | ||
|
||
msg = (r"Shape of passed values is \(3, 4, 5\), " | ||
r"indices imply \(5, 5, 4\)") | ||
msg = (r"Shape of passed values is \(4, 5, 3\), " | ||
r"indices imply \(5, 4, 5\)") | ||
with pytest.raises(ValueError, match=msg): | ||
Panel(np.random.randn(3, 4, 5), | ||
lrange(5), lrange(5), lrange(4)) | ||
|
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.
move to Reshaping section.
Reversed shapes in ValueError message when data shape does not match index shape in construction