Skip to content

fix std/var with complex array #61646

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

Merged
merged 3 commits into from
Jun 16, 2025

Conversation

randolf-scholz
Copy link
Contributor

@@ -1014,7 +1014,11 @@ def nanvar(
avg = _ensure_numeric(values.sum(axis=axis, dtype=np.float64)) / count
if axis is not None:
avg = np.expand_dims(avg, axis)
sqr = _ensure_numeric((avg - values) ** 2)
if values.dtype.kind == "c":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used an if-clause here to minimize performance impact for non-complex data.

@randolf-scholz
Copy link
Contributor Author

These failures seem unrelated, is the CI broken?

@mroeschke mroeschke added the Reduction Operations sum, mean, min, max, etc. label Jun 16, 2025
@mroeschke mroeschke added this to the 3.0 milestone Jun 16, 2025
@mroeschke mroeschke merged commit ea9c247 into pandas-dev:main Jun 16, 2025
48 checks passed
@mroeschke
Copy link
Member

Thanks @randolf-scholz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reduction Operations sum, mean, min, max, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series.std and Series.var give incorrect results for complex values.
2 participants