Just trying out pandas for the first time, and I am trying to sort a pivot table first by an index, then by the values in a series.
So far I've tried:
table = pivot_table(sheet1, values='Value', rows=['A','B'], aggfunc=np.sum)
# Sorts by value ascending, can't change to descending
table.copy().sort()
table
# The following gives me the correct ordering in values, but ignores index
sorted_table = table.order(ascending=False)
sorted_table
# The following brings me back to the original ordering
sorted_table = table.order(ascending=False)
sorted_table2 = sorted_table.sortlevel(0)
sorted_table2
What's the correct way to sort a pivot table by index then value?