# How to convert an array to a dataframe?

**URL:** <https://discourse.julialang.org/t/how-to-convert-an-array-to-a-dataframe/47233>\
**Category:** General Usage\
**Created:** [September 25, 2020, 12:51am UTC](https://discourse.julialang.org/t/how-to-convert-an-array-to-a-dataframe/47233 "2020-09-25T00:51:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DShiu](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@DShiu](https://discourse.julialang.org/u/DShiu)\
**Post date:** [September 25, 2020, 12:51am UTC](https://discourse.julialang.org/t/how-to-convert-an-array-to-a-dataframe/47233/1 "2020-09-25T00:51:53Z")

</div>

```julia
column = rand(Int64, 10)
DataFrame(column, [:col1])

```

This gives:

```julia
ERROR: ArgumentError: columns argument must be a vector of AbstractVector objects

```

---

<div class="post-metadata">

**Author:** ![kmundnic](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kmundnic](https://discourse.julialang.org/u/kmundnic)\
**Post date:** [September 25, 2020, 1:33am UTC](https://discourse.julialang.org/t/how-to-convert-an-array-to-a-dataframe/47233/2 "2020-09-25T01:33:26Z")

</div>

From the [docs](https://juliadata.github.io/DataFrames.jl/stable/man/getting_started/):

```julia
using DataFrames
df = DataFrame(A = 1:4, B = ["M", "F", "F", "M"])

```

In your case,

```julia
column = rand(Int64, 10)
df = DataFrame(col1 = column)

```

Note that when initializing, you don’t need to use symbols.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 25, 2020, 7:05am UTC](https://discourse.julialang.org/t/how-to-convert-an-array-to-a-dataframe/47233/3 "2020-09-25T07:05:48Z")

</div>

You almost had it - the error is telling you that the first argument needs to be a vector of vectors, rather than a vector:

```julia
julia> using DataFrames

julia> column = rand(5);

julia> DataFrame([column], [:col1]) # Note the enclosing [] around column!
5×1 DataFrame
│ Row │ col1 │
│ │ Float64 │
├─────┼───────────┤
│ 1 │ 0.487455 │
│ 2 │ 0.439289 │
│ 3 │ 0.496783 │
│ 4 │ 0.0520202 │
│ 5 │ 0.661149 │

```
