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

DataFrame editor should do a stable sort #3010

Closed
jondo opened this issue Feb 26, 2016 · 6 comments
Closed

DataFrame editor should do a stable sort #3010

jondo opened this issue Feb 26, 2016 · 6 comments

Comments

@jondo
Copy link
Contributor

jondo commented Feb 26, 2016

I am using Spyder 2.3.5.2 from WinPython-64bit-3.4.3.5.

I noticed that clicking column headers in the DataFrame editor does not sort the table in a stable way. This especially means that one cannot reach a hierarchical sorting.

@ccordoba12
Copy link
Member

I don't understand what you mean. Please post examples about what problem are you seeing and what's the expected output, as it's explicitly demanded in our issue template.

Also, for next time, please don't dismiss the template contents. That saves us a lot of time.

@jondo
Copy link
Contributor Author

jondo commented Feb 29, 2016

please don't dismiss the template contents

You are right. Strangely, I cannot come up with a small example. I will reopen this when I find an example again.

@jondo jondo closed this as completed Feb 29, 2016
@jondo
Copy link
Contributor Author

jondo commented Mar 1, 2016

Ok, I've got it now:

  • Define df = pd.DataFrame([[2,14],[2,13],[2,16],[1,3],[2,9],[1,15],[1,17],[2,2],[2,10],[1,6],[2,5],[2,8],[1,11],[1,1],[1,12],[1,4],[2,7]])
  • Open df in the DataFrame editor.
  • Try to sort hierarchically. For this, click the header of column '1', then the header of column '0'.

Expected result: df is hierarchically sorted by the columns '0' and '1'.

Observed result: Within the value '2' of column '0', the values of column '1' have become unsorted again.

Interestingly, the hierarchical sorting works for smaller DataFrames, e.g. when [1,17] is removed from the above example.

@jondo jondo reopened this Mar 1, 2016
@jitseniesen
Copy link
Member

I think this is quite easy to implement by using telling DataFrame.sort to use mergesort (which is stable) in the dataframe editor. A potential problem is that mergesort has a higher memory cost according to the numpy manual, but I don't think that's likely to be an issue for us.

@ccordoba12
Copy link
Member

PR coming? ;-)

@Nodd
Copy link
Contributor

Nodd commented Jun 13, 2016

@ccordoba12 Admit it, it's an automated answer ! ;o)

jitseniesen added a commit to jitseniesen/spyder that referenced this issue Jun 19, 2016
- Set ascending flag correctly, fixes spyder-ide#3020.
- Use mergesort so that sorting is stable, fixes spyder-ide#3010.
- Use .sort_values() because .sort() is deprecated since pandas 0.17.
@ccordoba12 ccordoba12 modified the milestones: v3.0beta4, v3.2 Jun 20, 2016
jitseniesen added a commit to jitseniesen/spyder that referenced this issue Jun 21, 2016
- Set ascending flag correctly, fixes spyder-ide#3020.
- Use mergesort so that sorting is stable, fixes spyder-ide#3010.
- Use .sort_values() because .sort() is deprecated since pandas 0.17.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants