Type of mean is not set correctly
See original GitHub issueDescribe 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:
- Created a year ago
- Comments:8 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.Noted. I’ve changed my code to use python’s round as a function and not as a method on the float.