I have datafram like this:
A B C D E F
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
and I create new column by merging columns after C by:
df['new'] = df[df.columns[3:]].apply(lambda x: ','.join(x.dropna().astype(str)), axis=1)
So, now result is:
A B C D E F new
1 2 3 4 5 6 4,5,6
7 8 9 10 11 12 10,11,12
13 14 15 16 17 18 16,17,18
But I want new column as list. like below:
A B C D E F new
1 2 3 4 5 6 [4,5,6]
7 8 9 10 11 12 [10,11,12]
13 14 15 16 17 18 [16,17,18]
what should I do?