Skip to content
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: DataFrame float reductions with object input #49618

Closed
rhshadrach opened this issue Nov 10, 2022 · 2 comments
Closed

BUG: DataFrame float reductions with object input #49618

rhshadrach opened this issue Nov 10, 2022 · 2 comments
Labels
Closing Candidate May be closeable, needs more eyeballs DataFrame DataFrame data structure Dtype Conversions Unexpected or buggy dtype conversions Needs Discussion Requires discussion from core team before further action Reduction Operations sum, mean, min, max, etc.

Comments

@rhshadrach
Copy link
Member

By "float reduction", I mean any reduction that would coerce bool or int to float - e.g. mean, std, skew, kurt.

Along with bool and int, we also coerce object to float:

print(pd.DataFrame(data=[[1]], columns=["a"], dtype=object).mean(axis=0))
# a    1.0
# dtype: float64

The reason we cast bool / int to float is to make the resulting dtype not value-dependent. However it's not clear to me if this is the correct thing to do with object. I think I would have expected to get object dtype back.

This was noticed because of the following inconsistency:

print(pd.DataFrame(columns=["a"], dtype=object).mean())
# a    NaN
# dtype: object

In the case of an empty frame with columns, we do end up with object dtype.

@rhshadrach rhshadrach added Dtype Conversions Unexpected or buggy dtype conversions Needs Discussion Requires discussion from core team before further action DataFrame DataFrame data structure Reduction Operations sum, mean, min, max, etc. labels Nov 10, 2022
@jbrockmendel
Copy link
Member

@rhshadrach im seeing object dtype on main. is this closed by one of your recent PRs?

@jbrockmendel jbrockmendel added the Closing Candidate May be closeable, needs more eyeballs label Mar 3, 2023
@rhshadrach
Copy link
Member Author

Thanks, closed by #51335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs DataFrame DataFrame data structure Dtype Conversions Unexpected or buggy dtype conversions Needs Discussion Requires discussion from core team before further action Reduction Operations sum, mean, min, max, etc.
Projects
None yet
Development

No branches or pull requests

2 participants