s = name.split('.')
label_name = s[0]
label = label_names.index(label_name)
id = int(s[1])
return label
test['label'] = test['name'].apply(lambda x: my_function(x))
Add Pandas column values in a for loop?