Right way to reverse a pandas DataFrame?

Here is my code: import pandas as pd data = pd.DataFrame({‘Odd’:[1,3,5,6,7,9], ‘Even’:[0,2,4,6,8,10]}) for i in reversed(data): print(data[‘Odd’], data[‘Even’]) When I run this code, i get the following error: Traceback (most recent call last): File “C:\Python33\lib\site-packages\pandas\core\generic.py”, line 665, in _get_item_cache return cache[item] KeyError: 5 During handling of the above exception, another exception occurred: Traceback (most recent … Read more

angular ng-repeat in reverse

How can i get a reversed array in angular? i’m trying to use orderBy filter, but it needs a predicate(e.g. ‘name’) to sort: <tr ng-repeat=”friend in friends | orderBy:’name’:true”> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> <td>{{friend.age}}</td> <tr> Is there a way to reverse original array, without sorting. like that: <tr ng-repeat=”friend in friends | orderBy:”:true”> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> <td>{{friend.age}}</td> <tr> … Read more

Python list sort in descending order

How can I sort this list in descending order? timestamps = [ “2010-04-20 10:07:30”, “2010-04-20 10:07:38”, “2010-04-20 10:07:52”, “2010-04-20 10:08:22”, “2010-04-20 10:08:22”, “2010-04-20 10:09:46”, “2010-04-20 10:10:37”, “2010-04-20 10:10:58”, “2010-04-20 10:11:50”, “2010-04-20 10:12:13”, “2010-04-20 10:12:13”, “2010-04-20 10:25:38” ] 6 Answers 6