# Unnesting columns of a data frame containing arrays

**URL:** <https://discourse.julialang.org/t/unnesting-columns-of-a-data-frame-containing-arrays/51526>\
**Category:** General Usage\
**Tags:** question, dataframes, data\_structures\
**Created:** [December 9, 2020, 1:47pm UTC](https://discourse.julialang.org/t/unnesting-columns-of-a-data-frame-containing-arrays/51526 "2020-12-09T13:47:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jolars](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jolars/32/15493_2.png) [@jolars](https://discourse.julialang.org/u/jolars)\
**Post date:** [December 9, 2020, 1:47pm UTC](https://discourse.julialang.org/t/unnesting-columns-of-a-data-frame-containing-arrays/51526/1 "2020-12-09T13:47:08Z")

</div>

Let’s say I have the following Julia data frame:

```julia
using DataFrames

d = DataFrame(a = Int64[], b = Array{Int64, 1}[])
push!(d, (1, [2, 3]))

1×2 DataFrame
 Row │ a b      
     │ Int64 Array… 
─────┼───────────────
   1 │ 1 [2, 3]

```

How can I unnest the **b** column so that I get

```julia
2×2 DataFrame
 Row │ a b     
     │ Int64 Int64 
─────┼──────────────
   1 │ 1 2
   2 │ 2 3

```

? (The real use case here is obviously more complicated.)

In R, I would do the following:

```r
library(tidyverse)

d <- tibble(a = 1, b = c(2, 3)) %>%
  nest(data = b)

unnest(d, data)
#> # A tibble: 2 x 2
#> a b
#> <dbl> <dbl>
#> 1 1 2
#> 2 1 3

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [December 9, 2020, 2:10pm UTC](https://discourse.julialang.org/t/unnesting-columns-of-a-data-frame-containing-arrays/51526/2 "2020-12-09T14:10:51Z")

</div>

you want `flatten(df, :b)`
