caravel_排序,添加

#add_derek

columns = fd.get('columns')or[]

#if columns != None and columns != '':

iflen(columns) >0:

collist=columns[0]

print(collist)

print(self.groupby)

print(df)

print('r9r9r9r99r9r9r')

#df_shadow=df

aa=df[collist]

bb=df[self.groupby]

cc=pd.merge(aa.to_frame(),bb.to_frame(),left_index=True,right_index=True)# make order col and display col

dd=cc.drop_duplicates([self.groupby])#drop duplicate

ee=dd.sort_values(by=collist)# make order

train_data=np.array(ee[self.groupby])

x_list=train_data.tolist()

df[self.groupby]=df['self.groupby'].astype('category')

df[self.groupby].cat.set_categories(x_list,inplace=True)

row=df.sort_values('月份',ascending=True)[self.metrics[0]].copy()

你可能感兴趣的:(caravel_排序,添加)