question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type of mean is not set correctly

See original GitHub issue

Describe the bug The return type of mean() is set as builtins.float where in practice it’s numpy.float64.

To Reproduce typing.py

from typing_extensions import reveal_type
import pandas as pd

val = pd.Series([True, False, True]).mean()
reveal_type(val)

mypy typing.py typing.py:5: note: Revealed type is "builtins.float"

In the interactive terminal:

In [1]: import pandas as pd
In [2]: val = pd.Series([True, False, True]).mean()
In [3]: type(val)
Out[3]: numpy.float64

Please complete the following information:

  • OS: Debian
  • OS: 11
  • python version: 3.9.7
  • version of type checker: mypy
  • version of installed pandas-stubs: 1.4.3.220704

Additional context This becomes a problem when using the round function on float, pd.Series([True, False, True]).mean().round() For which mypy gives this message: error: "float" has no attribute "round"

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Dr-Irvcommented, Jul 6, 2022

While the python code works, it is not supported by pandas. as it is undocumented. There is a goal in pandas to make the return type float, so we’ll leave the signature the way it is.

0reactions
rvanlaarcommented, Jul 6, 2022

Noted. I’ve changed my code to use python’s round as a function and not as a method on the float.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formula errors in Excel when list separator is not set correctly
Describes formula errors when list separator is not set correctly.
Read more >
What the value (not set) means - Analytics Help
(not set) is a placeholder name that Analytics uses when it hasn't received any information for the dimension you have selected. The reasons...
Read more >
Support Code 4102: Wrong Media Type or Paper Size
If the media type or paper size isn't set correctly on your printer, an orange light flashes and Support Code 4102 shows on...
Read more >
Measurements and Error Analysis - WebAssign
Types of Errors. Measurement errors may be classified as either random or systematic, depending on how the measurement was obtained (an instrument could...
Read more >
Additional Considerations – Research Methods in Psychology
Rejecting the null hypothesis when it is true is called a. Type I error . This error means that we have concluded that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found