Country,Population (million),Gold,Silver,Bronze,Total Grenada,0.10,1,0,0,1 Jamaica,2.74,4,4,4,12 Trinidad and Tobago,1.34,1,0,3,4 New Zealand,4.37,6,2,5,13 Bahamas,0.34,1,0,0,1 Slovenia,2.03,1,1,2,4
In [2]: medals = pd.read_csv('olympics.csv', skiprows=3)
In [3]: medals['Gold per million'] = medals['Gold'] / medals['Population (million)']
In [4]: medals.sort('Gold per million', ascending=False)[:20]['Gold per million'].plot(kind='bar')
In [18]: medals['Gold per million'].sort(ascending=False)[:20].plot(kind='bar')
fails with the following exception:
ValueError: This Series is a view of some other array, to sort in-place you must create a copy
which is rather uninformative for a beginner.
My conservative proposal to change the Series.sort() API is as follows:
Version 0.17: issue a deprecation warning for Series.sort() calls with no parameters (but still default to inplace=True)
Version 0.18: force passing inplace=True or inplace=False for calls to Series.sort()
Version 0.19: set the default for Series.sort() to inplace=False.
It would also be possible IMHO to jump straight to the second stage, requiring passing inplace=True or inplace=False for Series.sort() calls in v0.17.
I would be happy to submit pull requests for this if the maintainers give the proposal the green light.
Best wishes,
Ed
--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.