Reputation: 29
I would like to change the order of the column but the column name is time stamp. How can I change the order of timestamp column?
Here is the example of data I've got.
It is in data frame and the package I am using is pandas
and numpy
properties 2020-11-28 03:00:00 2020-12-26 02:00:00 2020-12-12 01:00:00
Percent 76.5 77.62 71.89
Power 718.828 717.949 718.828
I've used below query to change the order of the column but I've got error message saying
Key Error:'value not in index'
total_top4 = tot_top4[['THING DESCRIPTION','2020-11-28 03:00:00', '2020-12-12 01:00:00','2020-12-26 02:00:00']]
total_top4
Can someone please tell me how to change timestamp format column order?
Upvotes: 0
Views: 131
Reputation: 402
try to set the df using the columns attribute. I am assuming total_top4 is your dataframe.
total_top4.columns=['THING DESCRIPTION','2020-11-28 03:00:00', '2020-12-12 01:00:00','2020-12-26 02:00:00']
Please try and let me know if this helps you! Thanks
Upvotes: 1