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

Inconsistent mean over booleans #8734

Closed
vladfi1 opened this issue Nov 5, 2014 · 1 comment
Closed

Inconsistent mean over booleans #8734

vladfi1 opened this issue Nov 5, 2014 · 1 comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Groupby

Comments

@vladfi1
Copy link

vladfi1 commented Nov 5, 2014

It appears that the mean aggregate function is inconsistent when operating on boolean values.

from pandas import DataFrame

df1 = DataFrame({'a': [1, 1], 'bools': [True, True]})
df2 = DataFrame({'a': [1, 1], 'bools': [True, False]})

print df1.mean().bools # 1.0
print df2.mean().bools # 0.5

print df1.groupby('a').mean() # DataFrame with 1: True
print df2.groupby('a').mean() # DataFrame with 1: 0.5

For some reason the mean of a set of True values is True instead of 1.0, but only for GroupBy objects and not for DataFrame objects.

@jreback
Copy link
Contributor

jreback commented Nov 5, 2014

dupe if #7001

@jreback jreback closed this as completed Nov 5, 2014
@jreback jreback added IO CSV read_csv, to_csv Bug Dtype Conversions Unexpected or buggy dtype conversions Groupby and removed IO CSV read_csv, to_csv labels Nov 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Groupby
Projects
None yet
Development

No branches or pull requests

2 participants