-  
-   Notifications  You must be signed in to change notification settings 
- Fork 19.2k
Closed
Labels
BugGroupbyNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations
Milestone
Description
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
Metadata
Metadata
Assignees
Labels
BugGroupbyNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations