Answer the question
In order to leave comments, you need to log in
How to sort data in pandas in reverse?
How to sort data by index so that the table starts with the latest data and ends with the first one?
For example:
Date
Open High Low Close Volume
0 28-AUG-17 160.14 162.00 159.93 161.47 25965972
1 25-AUG-17 159.65 160.56 159.27 159.86 25480063
2 24-AUG-17 160.43 160.74 158.55 159.27 19818918
3 23-AUG-17 159.07 160.47 158.88 159.98 19399081
4 22-AUG-17 158.23 160.00 158.02 159.78 21604585
It was:
Date Open High Low Close Volume
4 28-AUG-16 150.14 162.00 149.93 121.47 25965972
3 25-AUG-16 152.65 160.56 149.27 139.86 25480063
2 24-Aug- 16 160.43 140.74 158.55 159.27 19818918
1 23-Aug-16 159.07 160.47 158.88 129.98 19399081
0 22-Aug-16 158.23 160.00 158.02 159.78 21604585
Answer the question
In order to leave comments, you need to log in
arr = ()
arr1 = numpy.sort(arr)
arr2 = arr1[:, ::-1]
print (arr2)
sort classically first, then reverse the order.
at least that's what it says in McKinney's book
https://pandas.pydata.org/pandas-docs/stable/gener...
As I understand it, the index does not have a name? Call it something, don't be stingy)))
Id Date Open High Low Close Volume
0 28-Aug-17 160.14 162.00 159.93 161.47 25965972
1 25-Aug-17 159.65 160.56 159.27 159.86 25480063
2 24-Aug-17 160.43 160.74 158.55 159.27 19818918
3 23-Aug-17 159.07 160.47 158.88 159.98 19399081
4 22-Aug-17 158.23 160.00 158.02 159.78 21604585
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question