-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: std
using numpy.float32
dtype gives incorrect result on contant array.
#57505
Comments
OS: Windows 10
Sorry, don't know how to make such "Installed Versions". Tried the same code with 1.26.3 numpy version, still no problems. |
You can use: pd.show_versions() |
@jamespreed Thank you very much! Here is my installed versions:
|
@jamespreed Just out of curious, can you try to create venv and reproduce this bug?
Create your file and try again. |
Ye, really interesting: package manager affects math results ʘ‿ʘ At least you know how to use |
Are you able to isolate whether it's the pandas or NumPy package that causes this? |
Can you provide your conda env export file? (or steps to create the env using conda) |
I am extremely confused now. The issue does NOT appear when clean installing via the following methods: venv
conda env with numpy, pip install pandas
clean conda env
|
The issue is In all of the above cases, installing
|
is this only on the new pandas version or does this also happen if you use an older version of pandas? |
It happens on Pandas 1.4.4, 1.5.3, 2.0.0, 2.1.0, 2.1.4, and 2.2.0 |
that means that it is most likely a bottleneck issue, could you report there? |
Looking at the linked issue, it appears very likely this is a bottleneck issue. Closing for now. |
Also, note you can disable the use of bottleneck with
You can also temporarily disable it for certain lines:
|
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
When using the numpy float32 dtype by passing either the string
'float32'
or the numpy dtypenp.float32
, the value of the standard deviation is incorrect for a constant array (array of identical values). It should return zero, but instead returns a value.Switching to using the Pandas float32 dtype alleviates the error, as does using
np.std
on the numpy values of the series.Expected Behavior
The expected behavior is the following evaluating to
True
Installed Versions
The text was updated successfully, but these errors were encountered: