Reputation: 63
I have a list of list, like:
X=[[1,1,2],[3,4,5],[8,1,9]]
and I have a dataframe with some columns, I will add a new column to my dataframe that each value of new column in each row is one of list of X, how can I do this?
to be more clear, for example, I have a dataframe in this image :
and I have a list like X. then I want a new dataframe like:
Upvotes: 0
Views: 786
Reputation: 24049
try this:
df = pd.DataFrame({'a': {0: '1', 1: '2', 2: '3'},
'b': {0: 's', 1: 'n', 2: 'k'}})
X=[[1,1,2],[3,4,5],[8,1,9]]
df['new_col'] = X
df
output:
Upvotes: 1