Skip to content

Series.mean() does not return an float #552

Closed
@alkatar21

Description

@alkatar21

Describe the bug
Series.mean() is typed as float, but actually returns a numpy.float64.

This errors because I need to call .item() to get the actual float.

To Reproduce

# pyright: strict
import pandas as pd

mean = pd.Series([1, 2, 3, 4]).mean()
print(type(mean)) # numpy.float64 instead of float
mean.item() # Cannot access member "item" for type "float"  Member "item" is unknown Pylance (reportGeneralTypeIssues)

Please complete the following information:

  • OS: Linux
  • OS Version 20.04
  • python 3.8.10
  • version of type checker: 1.1.293
  • version of installed pandas-stubs: Pylance v2023.2.31

Additional context
I must have the actual float for yaml.safe_dump.

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