How Sort_index works in Pandas

时间:2018-04-18 17:50:49

标签: python pandas

I was trying to undestand how sort_index works in pandas. I ma quite confused with the results I got when i tested with two dataframes.

I have df1 sorted with index 'pid'

df1:
pid,day,score1,score2
100,Fri,200,108
......
221,Wed,546,789
221,Sat,123,456

The second data frame sorted with index 'pid'

    df2:
pid,day,score1,score2
100,Fri,230,18
......
221,Sat,563,324
221,Wed,111,789

I couldn't understand why PID# 221 is sorted differently in both cases. Ideally both should follow same sorting as i am sorting by index.

Any help on this is highly appreciated.

0 个答案:

没有答案
相关问题