8000 Switch dataframe constructor to use dispatch by saulshanabrook · Pull Request #32844 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Switch dataframe constructor to use dispatch #32844

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

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
mypy fixes
  • Loading branch information
saulshanabrook committed Mar 19, 2020
commit 522029d34726f348619dde5c4c7de82561e23cae
8 changes: 3 additions & 5 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8569,15 +8569,13 @@ class _IterableExceptStringOrBytes(metaclass=_IterableExceptStringOrBytesMeta):
pass


@create_block_manager.register
def _create_block_manager_iterable(
data: _IterableExceptStringOrBytes, df, index, columns, dtype, copy
):
@create_block_manager.register(_IterableExceptStringOrBytes)
def _create_block_manager_iterable(data: abc.Iterable, df, index, columns, dtype, copy):
if not isinstance(data, (abc.Sequence, ExtensionArray)):
data = list(data)
if len(data) > 0:
if is_dataclass(data[0]):
data = dataclasses_to_dicts(data)
data = cast(List[dict], dataclasses_to_dicts(data))
if is_list_like(data[0]) and getattr(data[0], "ndim", 1) == 1:
if is_named_tuple(data[0]) and columns is None:
columns = data[0]._fields
Expand Down
0