I have a dataframe, it has two columns, one is called 'PTM_loc' and another one is called 'PTM_types'
data['PTM_loc']
0 24
1 24;30
2 22
3 19;20;66
4 16;30;50
data['PTM_typs']
0 S
1 S
2 T
3 S;T
4 S;Y;T
I would like to concat (or whatever you call this action) these columns together, and get a new column like this:
data['PTMs']
0 S24
1 S24;S30
2 T22
3 S19;T20;T66
4 S16;Y30;T50
Does anyone have any ideas?
You can use a list comprehension with a double
zip/zip_longest:Altentatively, for a pure pandas variant (just for fun, it's likely less efficient), use
ffillto fill the missing combinations:Output: