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

Call a constructor by interpolation

$
0
0

I need to programmatically initialize an empty DataFrame using a vector of names and a vector of types:

Here is an example of doing this explicitly:

DataFrame(mystrings=String[],myints=Int64[])
0×2 DataFrame

MWE for doing this programmatically:

nm = ["mystrings","myints"]
tps = (String,Int64)
expr = :(DataFrame($nm .= $tps))
eval(expr)

ERROR: MethodError: Cannot `convert` an object of type Type{String} to an object of type String

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images