code: def reorderbydf(df2,df1):
      
      df3=pd.DataFrame()
      for idx,row in df1.iterrows():
          df3=df3.append(df2.loc[idx,:])
      return df3
docs: Reorder rows of a dataframe by other dataframe
  
      :param df2: input dataframe
      :param df1: template dataframe