I have a pd dataframe with one column user_id and each row ends with "/tgroup..."
I want to create a new column group_id where each row will have the corresponding "tgroup..." matching user_id.
This is my implementation so far:
user_id
0 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-0
1 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-1
2 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-2
3 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-3
4 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-4
df['group_id'] = df['user_id'].apply(lambda x: re.findall('(^\t)',x))
print(df.head())
user_id group_id
0 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-0 []
1 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-1 []
2 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-2 []
3 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-3 []
4 87dce49a-f752-47f8-9bc4-b97a446a85f5\tgroup-4 []
Clearly lambda/regex method is not grabbing the string selection that I want.
Any ideas?