-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
support constructing Panel or Panel4D with scalar data, fixes #8285 #9640
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
@@ -888,6 +888,21 @@ def test_constructor(self): | |||
wp = Panel(vals, copy=True) | |||
self.assertIsNot(wp.values, vals) | |||
|
|||
# test when scalar data is used to construct a Panel | |||
# if dtype is not passed, it should be inferred | |||
value_and_dtype = [(1, int), (3.14, float), ('foo', np.object_)] |
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 the issue number here
ok, pls add a release note (this can go in 0.16.0) |
eae8083
to
09be167
Compare
dtype, data = _infer_dtype_from_scalar(data) | ||
values = np.empty([len(x) for x in passed_axes], dtype=dtype) | ||
values.fill(data) | ||
mgr = self._init_matrix(values, passed_axes, dtype=dtype, copy=copy) |
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.
I think you need to make copy= False
before you init the matrix (so it doesn't copy it again). Copy is irrelevant with a scalar anyhow.
09be167
to
cc8bf97
Compare
@jreback thanks it's fixed now |
support constructing Panel or Panel4D with scalar data, fixes #8285
@mortada thanks! |
this should fix #8285