# Store array in cells of DataFrame?

**URL:** <https://discourse.julialang.org/t/store-array-in-cells-of-dataframe/27088>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 1, 2019, 6:38pm UTC](https://discourse.julialang.org/t/store-array-in-cells-of-dataframe/27088 "2019-08-01T18:38:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 1, 2019, 6:38pm UTC](https://discourse.julialang.org/t/store-array-in-cells-of-dataframe/27088/1 "2019-08-01T18:38:15Z")

</div>

I’m having trouble with the following behavior:

```julia
julia> df = DataFrame(a = Array[], b = Int[]); push!(df, [[1,2,3], 6])
1×2 DataFrame
│ Row │ a │ b │
│ │ Array │ Int64 │
├─────┼───────────┼───────┤
│ 1 │ [1, 2, 3] │ 6 │

```

but then:

```julia
julia> df = Dict("a" => [1,2,3], "b" => 6) |> DataFrame
3×2 DataFrame
│ Row │ a │ b │
│ │ Int64 │ Int64 │
├─────┼───────┼───────┤
│ 1 │ 1 │ 6 │
│ 2 │ 2 │ 6 │
│ 3 │ 3 │ 6 │

```

how to make the second one work like the first?

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [August 1, 2019, 6:54pm UTC](https://discourse.julialang.org/t/store-array-in-cells-of-dataframe/27088/2 "2019-08-01T18:54:39Z")

</div>

It’s getting confused about what shapes you are trying to broadcast to, because the columns have different sizes (3 and 0). You should think of the `Dict` as the dataframe itself, that is a dict of _columns_.

This works

```julia
DataFrame(Dict("a"=>[[1,2,3]], "b"=>[6]))

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 1, 2019, 6:55pm UTC](https://discourse.julialang.org/t/store-array-in-cells-of-dataframe/27088/3 "2019-08-01T18:55:19Z")

</div>

ah… a classic `[[]]`, should have though about this.
