def row_number(df,groupby=[],orderby=[],asc=[],row_num_name='rNo'):
'''
利用padas实现row_number()的功能
df——要处理的dataframe
groupby:要分组的变量,必须是list
orderby:要排序的变量,必须是list,结果会优先按照groupby+orderby排序
asc:ordery中逐一对应的排序规则,必须是list,且必须与orderby等长
row_num_name:列号存放的位置
'''
df[row_num_name] = 1
df.sort_values(by=groupby+orderby,ascending=[True]*len(groupby)+asc, inplace=True)
df[row_num_name]=df.groupby(groupby)[row_num_name].cumsum()
return df