I want to know the related station code in column 'stasjon-kd' for both maximum and minimum value of the column 'std-tid' which is grouped by tog-nr. I have written the code below. but it gives me error.
def stasjon_fra_to(path):
stasjon_kd,std_tid = path
np.where('std_tid' == arr.max(),'stasjon_kd',NA)
std_1['Stajon'] = std_1[['stasjon_kd','std_tid']].apply(stasjon_fra_to)
The error is :
NameError: ("global name 'arr' is not defined", u'occurred at index stasjon_kd')
Although I am not sure if the codes above will lead me to the right answer.