3
votes

I have a vector a = [1,2,3]. I want to convert it into a DataFrame with

convert(DataFrame, a)

but this throws a MethodError:

ERROR: MethodError: Cannot `convert` an object of type Array{Int64,1} to an object of type DataFrame

The command

convert(DataFrame, a')

works, but I actually want a 3×1 column vector.

Is there any other method that can do this?

1

1 Answers

3
votes

Just write:

julia> DataFrame(a=a)
3×1 DataFrame
 Row │ a
     │ Int64
─────┼───────
   1 │     1
   2 │     2
   3 │     3

to give the column name :a.