Given a dataframe df
, (real life is a +1000 row df). Elements of ColB
are lists of lists.
ColA ColB
0 'A' [['a','b','c'],['d','e','f']]
1 'B' [['f','g','h'],['i','j','k']]
2 'A' [['l','m','n'],['o','p','q']]
How can efficiently create a ColC
that is a string using the elements in the different columns, like this:
ColC
'A>+a b:c,+d e:f'
'B>+f g:h,+i j:k'
'A>+l m:n,+o p:q'
I tried with df.apply
along these lines, inspired by this:
df['ColC'] = df.apply(lambda x:'%s>' % (x['ColA']),axis=1)
This works for the first 2 elements of the string. Having a hard time with the rest.