I am trying to figure out how to sort the Series generated as a result of a groupby aggregation in a smart way.
I generate an aggregation of my DataFrame like this:
means = df.testColumn.groupby(df.testCategory).mean()
This results in a Series. I now try to sort this by value, but get an error:
means.sort()
...
-> Exception: This Series is a view of some other array, to sort in-place you must create a copy
I then try creating a copy:
meansCopy = Series(means)
meansCopy.sort()
-> Exception: This Series is a view of some other array, to sort in-place you must create a copy
How can I get this sort working?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…