Skip to content

dict argument to pd.Series constructor should allow Timestamp and tuple as keys #831

@Dr-Irv

Description

@Dr-Irv

Additional migration issues for the pd.Series constructor involve passing a dictionary. It fails with a Timestamp or multi-index key whereas before it did not:

sr1 = pd.Series(
        {
            pd.Timestamp(2023, 1, 2): "b",
        }
    )

    sr2 = pd.Series(
        {
            ("a", "b"): "c",
        }
    )
test.py:172: error: Need type annotation for "sr1"  [var-annotated]
test.py:174: error: Dict entry 0 has incompatible type "Timestamp": "str"; expected "str": "ndarray[Any, Any]"  [dict-item]
test.py:178: error: Need type annotation for "sr2"  [var-annotated]
test.py:180: error: Dict entry 0 has incompatible type "Tuple[str, str]": "str"; expected "str": "ndarray[Any, Any]"  [dict-item]

Originally posted by @amgcc in #826 (comment)

Might be best to allow Hashable as the dict key.

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