Assuming I have a df:
df=pd.DataFrame({'a':[1,2,3],'b':[4,5,6]})
All I want is to add a new column, c, with a constant list (for example: [7,8,9,10]).
When I try:
df['c']=[7,8,9,10]
I get:
ValueError: Length of values does not match length of index
I tried to play also with loc, at, ix - but couldn't figure it out.
An ugly workaround I found is to do something like:
df['c'] = df['b'].apply(lambda x: [7,8,9,10])
But there must be a more elegant way to do it.