Skip to content

to_numpy does not reflect S1 in pd.Series[S1] #1409

@cmp0xff

Description

@cmp0xff

Description

dtype of the resulting np_1darray from to_numpy does not reflect the typing of the Series

To Reproduce

Script

from typing import reveal_type

import pandas as pd

reveal_type(s := pd.Series([True]))  # Series[bool]
reveal_type(s.to_numpy())  # problem: np_1darray[Any]

reveal_type(s := pd.Series([1]))  # Series[int]
reveal_type(s.to_numpy())  # problem: np_1darray[Any]

Indicate which type checker you are using (mypy or pyright).

pyright

Messages from the type checker

Inline commented in the script

Please complete the following information

  • version of type checker: 1.1.406
  • version of installed pandas-stubs: main

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsSeriesSeries data structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions