How can I create a DataFrame with many columns programatically?

You can use .=> to broadcast the Pair operator:

julia> DataFrame(col_names .=> [randn(10) for _ in eachindex(col_names)])
10×48 DataFrame. Omitted printing of 42 columns
│ Row │ aa2001    │ ba2001    │ ca2001    │ da2001    │ ab2001     │ bb2001    │
│     │ Float64   │ Float64   │ Float64   │ Float64   │ Float64    │ Float64   │
├─────┼───────────┼───────────┼───────────┼───────────┼────────────┼───────────┤
│ 1   │ 0.187453  │ 0.922989  │ -1.8337   │ 1.10598   │ 0.2527     │ -1.26025  │
│ 2   │ -0.698976 │ 0.0275297 │ -0.779797 │ 0.325134  │ 0.184392   │ -0.541654 │
│ 3   │ -0.533002 │ 0.617138  │ -0.721395 │ -1.4459   │ -0.109285  │ 0.943458  │
│ 4   │ 2.59956   │ -0.24512  │ -0.556589 │ -1.33378  │ 2.12868    │ 0.856728  │
│ 5   │ 1.99969   │ 1.69739   │ -0.374264 │ 0.269507  │ -0.604224  │ 0.612185  │
│ 6   │ -0.136302 │ 0.922046  │ 1.21671   │ 1.17714   │ 0.90012    │ -0.58445  │
│ 7   │ 0.431472  │ 1.08326   │ -1.8062   │ -1.42047  │ 0.990874   │ -2.76279  │
│ 8   │ -0.602431 │ -0.300705 │ -0.184261 │ 0.613706  │ 0.232971   │ -0.548315 │
│ 9   │ -0.437662 │ -0.808732 │ -0.714415 │ 1.16602   │ 0.00941199 │ -0.352265 │
│ 10  │ 1.10546   │ 1.38544   │ -0.329173 │ -0.765127 │ 0.605886   │ 1.60454   │
4 Likes