daily log 11.11.20
less than 1 minute read
df['supervisor_chain_split'] = df.apply(lambda x: x['supervisor_chain'].split(' reports to -- '), axis=1)
df['supervisor_chain_split_len'] = df.apply(lambda x: len(x['supervisor_chain_split']), axis=1)
def get_all_sups(supervisor_chain, level):
try:
return supervisor_chain[level]
except:
return ''
df['supervisor_1'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 0), axis=1)
df['supervisor_2'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 1), axis=1)
df['supervisor_3'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 2), axis=1)
df['supervisor_4'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 3), axis=1)
df['supervisor_5'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 4), axis=1)
df['supervisor_6'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 5), axis=1)
df['supervisor_7'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 6), axis=1)
df['supervisor_8'] = df.apply(lambda x: get_all_sups(x['supervisor_chain_split'], 7), axis=1)