Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

How can I create a DataFrame with many columns programatically?

$
0
0

If I want to create a DataFrame with just 2 columns I can do:

DataFrame(a=rand(Normal(0, 1), 10), b=rand(Normal(0, 1), 10))

But what if I want to create a DataFrame with hundreds or thousands of columns with a given name?

For example with the following column names, just 48 for this example, (or whatever other container you prefer).

vec(map(IterTools.product(‘a’:‘d’, ‘a’:‘d’, string.(2001:2003))) do (x, y, z) xy’_’*z end)

And for this example we will also fill each column with

rand(Normal(0, 1), 10)

I will use it later to create an example for benchmarking purposes.

6 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles