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: strange behaviour in quantile with group by #33569

Closed
abdullahodibat opened this issue Apr 15, 2020 · 1 comment · Fixed by #33644
Closed

BUG: strange behaviour in quantile with group by #33569

abdullahodibat opened this issue Apr 15, 2020 · 1 comment · Fixed by #33644
Labels
Bug Groupby Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@abdullahodibat
Copy link

abdullahodibat commented Apr 15, 2020

is this a bug in pandas? why null values in the grouped by field break the quantile?

df = pd.DataFrame({
    'category': ['A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B'],
    'value': [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]
})
quantiles = df.groupby('category')['value'].quantile(0.75)
print(quantiles)

df2 = pd.DataFrame({
    'category': ['A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B', np.nan],
    'value': [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6,1]
})
quantiles2 = df2.groupby('category')['value'].quantile(0.75)
print(quantiles2) 

produces this output:

category
A    4.75
B    4.75
Name: value, dtype: float64
category
A    3.75
B    3.75
Name: value, dtype: float64

im using pandas 1.0.3

@abdullahodibat abdullahodibat added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 15, 2020
@dsaxton dsaxton added Groupby Numeric Operations Arithmetic, Comparison, and Logical operations and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 15, 2020
@simonjayhawkins
Copy link
Member

Thanks @abdullahodibat for the report. duplicate of #33200 (comment)

im using pandas 1.0.3

this is a regression between 0.24 and 0.25 (#20405)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Groupby Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
4 participants