def _ros_group_rank(df, dl_idx, censorship):
 ranks = df.copy()
 ranks.loc[:, 'rank'] = 1
 ranks = ranks.groupby(by=[dl_idx, censorship])['rank'].transform((lambda g: g.cumsum()))
 return ranks

def _ros_group_rank ( df , dl_idx , censorship ) : ranks = df . copy ( ) ranks . loc [ : , 'rank' ] = 1 ranks = ranks . groupby ( by = [ dl_idx , censorship ] ) [ 'rank' ] . transform ( ( lambda g : g . cumsum ( ) ) ) return ranks
ranks each observation within the data groups .