Process string in Pandas Dataframe rows to comma-delimitered chars

I have a dataframe, with data in each row as such.


How can I process the sequence strings in each row, such that the format will be as such?

[M, K, E, Y, G, E, D, L, K]

I tried

get_seq_str = ','.join(test_df.loc[0]['seq_1'])

However, when I append it to the dataframe, there is a single quotation mark at the start and end of each string, which I do not want.

['M, K, E, Y, G, E, D, L, K']

How can I strip the single quotation marks?

>Solution :

IIUC, you can try apply list to string value

df['col_list'] = df['col'].apply(list)

         col                     col_list
0  MKEYGEDLK  [M, K, E, Y, G, E, D, L, K]

Leave a Reply