Input Dataframe:
I am trying to pivot my df by sorting Time Column in column wise
my output df:

Pivoting df wont give Time in sorted order. Is there any alternate way to do ?
Input Dataframe:
I am trying to pivot my df by sorting Time Column in column wise
my output df:

Pivoting df wont give Time in sorted order. Is there any alternate way to do ?
You need reindex by unique values of column Loc_Time with sort_values by column Time, because pivot by default sorting:
df1 = df.pivot('Group','Loc_Time','Value')
df1 = df1.reindex(columns=df.sort_values('Time')['Loc_Time'].unique())
print (df1)
Loc_Time loc1_Week1 loc2_Week1 loc3_Week1 loc1_Week2 loc2_Week2 \
Group
prod1 10 12 14 11 13
prod2 20 22 24 21 23
Loc_Time loc3_Week2
Group
prod1 15
prod2 25
Detail:
print (df.sort_values('Time')['Loc_Time'].unique())
['loc1_Week1' 'loc2_Week1' 'loc3_Week1' 'loc1_Week2' 'loc2_Week2'
'loc3_Week2']