Say I have some dataframe df. I would like to add to it four columns ['A', 'B', 'C, 'D'] that do not exist yet, and that will hold a constant row vector [1, 2, 3, 4].
When I try to do:
df[new_columns] = [1,2,3,4]
it fails (saying ['A', 'B', 'C, 'D'] is not in index).
How can I create multiple columns dynamically in Pandas? Do I always have to use append for something like this? I remember reading (e.g. in @Jeff's comment to this question) that in newer versions the dynamic creation of columns was supported. Am I wrong?