Adding multiple new columns to dataframe?

  1. You do not need to know the list of columns upfront as push! has cols=:union option that will handle this
  2. If you know the list of columns upfront then it is easier to write:
DataFrame([:c1, :c2, :c3] .=> Ref([]))

or

DataFrame(fill([], 3), [:c1, :c2, :c3])

(in my original answer I thought you do not know the list of columns when creating a data frame)

4 Likes