Skip to content

DataFrame.__getitem__ returns wrong type for a dict_keys object #770

Closed
@gandhis1

Description

@gandhis1
import pandas as pd

some_columns = {
    "a": 1,
    "b": 2,
}
x  = pd.DataFrame.from_dict(some_columns)
y = x[some_columns.keys()]
reveal_type(y)  # note: Revealed type is "pandas.core.series.Series[Any]"

__getitem__ with a Generator is already annotated correctly, not clear to me why it doesn't use that overload here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions