Skip to content

pandas.Dataframe should accept an iterator of dicts #392

@gelineau

Description

@gelineau

Describe the bug
DataFrame constructor accepts data in the form of an iterator of dicts, but mypy raises an error.

To Reproduce

import pandas as pd

data = [{"a": 1, "b": 2}, {"a": 3, "b": 5}]
p = pd.DataFrame(iter(data))
$ mypy try_stubs.py 
try_stubs.py:5: error: Argument 1 to "DataFrame" has incompatible type "Iterator[Dict[str, int]]"; expected "Union[Union[Sequence[Any], ndarray[Any, Any], Series[Any], Index], DataFrame, Dict[Any, Any], Iterable[Union[Union[Sequence[Any], ndarray[Any, Any], Series[Any], Index], Tuple[Hashable, Union[Sequence[Any], ndarray[Any, Any], Series[Any], Index]]]], None]"
Found 1 error in 1 file (checked 1 source file)

Please complete the following information:

  • OS: Linux Ubuntu
  • OS Version [e.g. 22]: 1.5.0.221012
  • python version 3.8.13
  • version of type checker: mypy 0.982
  • version of installed pandas-stubs: 1.5.0.221012

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions