Skip to content

ENH: DataFrame sort columns by rows: sort_values(axis=1) #13622

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

Closed
wants to merge 5 commits into from

Conversation

IamJeffG
Copy link
Contributor

@IamJeffG IamJeffG changed the title Gh10806 DataFrame sort columns by rows: sort_values(axis=1) Jul 11, 2016
@codecov-io
Copy link

codecov-io commented Jul 12, 2016

Current coverage is 84.38%

Merging #13622 into master will increase coverage by 0.04%

@@             master     #13622   diff @@
==========================================
  Files           138        142     +4   
  Lines         51100      51222   +122   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43097      43223   +126   
+ Misses         8003       7999     -4   
  Partials          0          0          

Powered by Codecov. Last updated by 65849d3...ea2d89e

@IamJeffG IamJeffG changed the title DataFrame sort columns by rows: sort_values(axis=1) ENH: DataFrame sort columns by rows: sort_values(axis=1) Jul 12, 2016
@jreback jreback added Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jul 12, 2016
@@ -229,6 +229,7 @@ Other enhancements
- ``pd.read_html()`` has gained support for the ``decimal`` option (:issue:`12907`)
- A top-level function :func:`union_categorical` has been added for combining categoricals, see :ref:`Unioning Categoricals<categorical.union>` (:issue:`13361`)
- ``Series`` has gained the properties ``.is_monotonic``, ``.is_monotonic_increasing``, ``.is_monotonic_decreasing``, similar to ``Index`` (:issue:`13336`)
- ``DataFrame.sort_values()`` has gained support for re-ordering columns by index label (:issue:`10806`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not clear what actually you are changing. This is for axis 1 support for by

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't they mean the same thing? (by is always required sort_values, and axis 1 is equivalent to "columns".) See if the new wording in 2773cdf hits what you're getting at, otherwise can you please specify?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rewording in that commit is good! (exactly what I wanted to suggest to combine both :-))

Maybe just "with" after "columns"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jorisvandenbossche
Copy link
Member

Looks good. @jreback OK for you?

@jorisvandenbossche jorisvandenbossche added this to the 0.19.0 milestone Jul 14, 2016
@@ -229,6 +229,7 @@ Other enhancements
- ``pd.read_html()`` has gained support for the ``decimal`` option (:issue:`12907`)
- A top-level function :func:`union_categorical` has been added for combining categoricals, see :ref:`Unioning Categoricals<categorical.union>` (:issue:`13361`)
- ``Series`` has gained the properties ``.is_monotonic``, ``.is_monotonic_increasing``, ``.is_monotonic_decreasing``, similar to ``Index`` (:issue:`13336`)
- ``DataFrame.sort_values()`` has gained `axis=1` support to re-order columns with `by=index_label` (:issue:`10806`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use double-backquotes around axis=1 and by=index_label (though I am not entirely sure what that means). you can say by= I think the index_label is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by=index_label is straight from your issue title: #10806 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, yeah it is. I don't even remember what it is! hah, and a user certainly won't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The double backticks I understand. As for re-wording with respect to by, my previous commit did not specify this but you said that was unclear too. Could you please specify how you'd like this line to read?

Copy link
Member

@jorisvandenbossche jorisvandenbossche Jul 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback What do you think of ".. support to re-order the columns based on the values in a row using df.sort_values(by='index_label', axis=1))"

Could also add a small example

@@ -229,6 +229,13 @@ Other enhancements
- ``pd.read_html()`` has gained support for the ``decimal`` option (:issue:`12907`)
- A top-level function :func:`union_categorical` has been added for combining categoricals, see :ref:`Unioning Categoricals<categorical.union>` (:issue:`13361`)
- ``Series`` has gained the properties ``.is_monotonic``, ``.is_monotonic_increasing``, ``.is_monotonic_decreasing``, similar to ``Index`` (:issue:`13336`)
- ``DataFrame`` has gained support to re-order the columns based on the values in a row using ``df.sort_values(by='index_label', axis=1)`` (:issue:`10806`)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just this sentence is fine, but use: df.sort_values(by=...., axis=1)

@jreback
Copy link
Contributor

jreback commented Jul 20, 2016

ok minor comments, ps rebase and ping on green.

@jorisvandenbossche
Copy link
Member

@IamJeffG fixed the remaining comments when merging (we already asked you to update the whatsnew sentence enough :-))
Thanks a lot for the enhancement!

@IamJeffG
Copy link
Contributor Author

Thanks for taking care of it @jorisvandenbossche !

@jorisvandenbossche
Copy link
Member

(and now your geopandas PR .. :-) I try to take a look this evening!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG/ENH: sort_values(by=index_label, axis=1)
4 participants