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: quantile ignores axis kwarg #7312

Merged
merged 1 commit into from
Jun 11, 2014

Conversation

TomAugspurger
Copy link
Contributor

Closes #7306

We may want to wait on this till later today while I figure out what will happen in #7308

@TomAugspurger
Copy link
Contributor Author

This should be ok once Travis passes.

One odd thing is that numeric_only is always considered by column, even when axis=1.
So if you have something like

[[1,    2,  3],
 ['a', 'b', 4]]

It will exclude the first two columns since they aren't numeric. But this is the same as the previous behavior.

@TomAugspurger
Copy link
Contributor Author

Just to expand on that last comment. As before, we get:

In [34]: df
Out[34]: 
   0  1  2
0  1  2  3
1  a  b  4

In [35]: df.quantile(.5, axis=1)
Out[35]: 
0    3
1    4
dtype: float64

So the first two columns are excluded since they're non-numeric, so we're doing quantile on just the last column:

In [38]: df[2]
Out[38]: 
0    3
1    4
Name: 2, dtype: int64

Since axis=1, we take the median of each length 1 array and get the same thing back.

What I think should happen is we transpose first, and see that the first col is numeric and calculate the quantile on that column:

In [52]: df.T
Out[52]: 
   0  1
0  1  a
1  2  b
2  3  4

So df.quantile(.5, axis=1) should be equivalent to df.T.quantlie(.5, axis=0)

But this would potentially break existing code so I'll hold off on that till the future.

@TomAugspurger
Copy link
Contributor Author

I added one more test covering this; I'll merge when that's green.

@jreback jreback added this to the 0.14.1 milestone Jun 4, 2014
@jreback
Copy link
Contributor

jreback commented Jun 4, 2014

gr8 looks good

@jreback jreback merged commit b43d513 into pandas-dev:master Jun 11, 2014
@jreback
Copy link
Contributor

jreback commented Jun 11, 2014

thanks @TomAugspurger

@TomAugspurger TomAugspurger deleted the quantile-axis branch November 3, 2016 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.quantile ignores axis parameter
2 participants