-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
BUG: DataFrame fail to construct when data is list and columns is nested list for MI #32202
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 1 commit
7e461a1
1314059
8bcb313
24c3ede
dea38f2
cd9e7ac
e5e912b
e609188
c8ee822
07ffde2
b3f3da0
2f2054c
9176389
ed02384
d3b0c50
a5e0d10
6073ed7
e8f6d67
559b5d6
a452816
3fd6743
2428edb
fe18e50
a5d159b
7516964
86bd699
30a70a7
a6cb139
ed6dc4a
f058d2c
2852579
493ac33
3ecd6b8
851a3e1
9860985
ffc6561
a028c33
5af0f8e
9eda16a
35e92ea
44af738
d0a10e4
1700e5d
8a036e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
constructors before passing them to a BlockManager. | ||
""" | ||
from collections import abc | ||
from typing import Iterable, Optional, Union | ||
from typing import Iterable, Optional, Tuple, Union | ||
|
||
import numpy as np | ||
import numpy.ma as ma | ||
|
@@ -512,7 +512,9 @@ def to_arrays(data, columns, coerce_float=False, dtype=None): | |
return _list_to_arrays(data, columns, coerce_float=coerce_float, dtype=dtype) | ||
|
||
|
||
def _list_to_arrays(data, columns, coerce_float=False, dtype=None): | ||
def _list_to_arrays( | ||
data, columns, coerce_float=False, dtype=None | ||
) -> Tuple[list, Iterable]: | ||
if len(data) > 0 and isinstance(data[0], tuple): | ||
content = list(lib.to_object_array_tuples(data).T) | ||
else: | ||
|
@@ -527,7 +529,9 @@ def _list_to_arrays(data, columns, coerce_float=False, dtype=None): | |
return result, columns | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def _list_of_series_to_arrays(data, columns, coerce_float=False, dtype=None): | ||
def _list_of_series_to_arrays( | ||
data, columns, coerce_float=False, dtype=None | ||
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. can any of the args be typed? coerce_float should be easy 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. added types for all input argument |
||
) -> Tuple[list, Iterable]: | ||
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. Same comment as above |
||
if columns is None: | ||
# We know pass_data is non-empty because data[0] is a Series | ||
pass_data = [x for x in data if isinstance(x, (ABCSeries, ABCDataFrame))] | ||
|
@@ -560,7 +564,9 @@ def _list_of_series_to_arrays(data, columns, coerce_float=False, dtype=None): | |
return values.T, columns | ||
|
||
|
||
def _list_of_dict_to_arrays(data, columns, coerce_float=False, dtype=None): | ||
def _list_of_dict_to_arrays( | ||
data, columns, coerce_float=False, dtype=None | ||
) -> Tuple[list, Iterable]: | ||
""" | ||
Convert list of dicts to numpy arrays | ||
|
||
|
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.
If you can add sub-types for List and Iterable would be even better