Skip to content

BUG/TST: Include sem & count in all_numeric_reductions #49759

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 10 commits into from
Nov 28, 2022

Conversation

mroeschke
Copy link
Member

The sem bug with Arrow types could be backported to 1.5.x but given the larger testing changes IMO it's fine for 2.0

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite Numeric Operations Arithmetic, Comparison, and Logical operations Arrow pyarrow functionality labels Nov 17, 2022
@mroeschke mroeschke added this to the 2.0 milestone Nov 18, 2022
numerator = pc.stddev(data, skip_nulls=skipna, **kwargs)
denominator = pc.sqrt_checked(
pc.subtract_checked(
pc.count(self._data, skip_nulls=skipna), kwargs["ddof"]
Copy link
Member

Choose a reason for hiding this comment

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

is kwargs['ddof'] not relevant here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I suppose this only applies in the stddev call.

When comparing to ser.astype("Float64").sem() the results were off, and removing kwargs["ddof"] aligned this pyarrow sem to nullable dtype sem.

Copy link
Member

Choose a reason for hiding this comment

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

the test changes all look good. this change i dont know enough to form an opinion on. if youre confident its right then LGTM. otherwise lets find an appropriate person to double-check

Copy link
Member Author

Choose a reason for hiding this comment

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

I think based on the nanops.nansem implementation, I'm fairly sure these align

pandas/pandas/core/nanops.py

Lines 1033 to 1042 in 3fffb6d

nanvar(values, axis=axis, skipna=skipna, ddof=ddof, mask=mask)
mask = _maybe_get_mask(values, skipna, mask)
if not is_float_dtype(values.dtype):
values = values.astype("f8")
count, _ = _get_counts_nanvar(values.shape, mask, axis, ddof, values.dtype)
var = nanvar(values, axis=axis, skipna=skipna, ddof=ddof)
return np.sqrt(var) / np.sqrt(count)

@mroeschke
Copy link
Member Author

Going to push this one in since the pyarrow sem implementation matches the nanops.sem one. If both are wrong at least we have a test now that said both should be aligned.

@mroeschke mroeschke merged commit 8b227f3 into pandas-dev:main Nov 28, 2022
@mroeschke mroeschke deleted the tst/cln/fixture_reduction branch November 28, 2022 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Numeric Operations Arithmetic, Comparison, and Logical operations Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants