-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
[ArrayManager] DataFrame constructor from ndarray #40441
[ArrayManager] DataFrame constructor from ndarray #40441
Conversation
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
@@ -304,10 +305,26 @@ def ndarray_to_mgr( | |||
index, columns = _get_axes( | |||
values.shape[0], values.shape[1], index=index, columns=columns | |||
) | |||
values = values.T | |||
|
|||
_check_values_indices_shape_match(values, index, columns) |
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.
By moving values = values.T
below _check_values_indices_shape_match
, that function doesn't need to take the transposed shapes into account (and can be used for both AM and BM).
for i in range(values.shape[1]) | ||
] | ||
else: | ||
if is_datetime_or_timedelta_dtype(values.dtype): |
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 check is redundant
xref #39146
Currently, the
DataFrame(ndarray)
construction for ArrayManager still went through BlockManager and thenmgr_to_mgr
conversion, which is less efficient.This PR adds a check in
ndarray_to_mgr
for directly creating an ArrayManager.It's still WIP, because there are still some validation steps that are now done inside BlockManager/Block inits, that need to be factored out / shared / added to ArrayManager path.