Let’s say I have the following Julia data frame:
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
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:
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