0

I have a DF(dataframe) that was created by taking a list of DF's with concat as such:

conc_list = pandas.concat(DF_list, keys=range(len(DF_list)), names= ['one','for_date_time_object'], sort= True)

but it puts the zeros at the end of the dataframe.

  
for_date_time_object  one
2018-09-26 05:30:00   1      1537939800
                      2      1537939800
                      3      1537939800
2018-09-26 05:35:00   1      1537940100
2018-09-26 05:40:00   1      1537940400
2018-09-26 05:45:00   1      1537940700
                      2      1537940700
2018-09-26 05:50:00   1      1537941000
2018-09-26 05:55:00   1      1537941300
2018-09-26 06:00:00   1      1537941600

2018-11-07 05:30:00   0      1541595900
2018-11-07 05:31:00   0      1541595960
2018-11-07 05:32:00   0      1541596020
2018-11-07 05:33:00   0      1541596080
2018-11-07 05:34:00   0      1541596140

how can I get it to sort from 0-9?

for_date_time_object  one
2018-09-26 05:30:00   0      1537939800
                      1      1537939800
                      2      1537939800
                      3      1537939800
2018-11-07 05:31:00   0      1541595960
2018-11-07 05:32:00   0      1541596020
2018-11-07 05:33:00   0      1541596080
2018-11-07 05:34:00   0      1541596140
2018-09-26 05:35:00   0      1537940100
2018-09-26 05:35:00   1      1537940100
2018-11-07 05:36:00   0      1541595960
2018-11-07 05:37:00   0      1541596020
2018-11-07 05:38:00   0      1541596080
2018-11-07 05:39:00   0      1541596140
2018-09-26 05:40:00   0      1537940400
2018-09-26 05:40:00   1      1537940400                        

Thanks for the help.

  • Thanks everyone for the look, along with Zanshin and Alok Shrestha for the answers. Upon recreating the problem with some random generated data I found that I had not equated my variable to the new instance earlier in my code, and that lead to the problem I was having. – Bryan Kanagawa Dec 06 '18 at 22:47
  • if the answers were helpful you might accept and upvote – Zanshin Dec 07 '18 at 05:30

2 Answers2

0

If I understand correctly, try this :

conc_list.sort_values('one')
SMBiggs
  • 11,034
  • 6
  • 68
  • 83
Zanshin
  • 1,262
  • 1
  • 14
  • 30
-1

If you have a column name for the third column, you can try multi level sort with sorting by third column then by second column (one). Refer to https://stackoverflow.com/a/17141755/3544368

Alok
  • 42
  • 6