# Is there any function in julia equivalent to pandas explode function

**URL:** <https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096>\
**Category:** Data\
**Tags:** dataframes\
**Created:** [January 24, 2022, 2:39am UTC](https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096 "2022-01-24T02:39:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frankiewaang](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@Frankiewaang](https://discourse.julialang.org/u/Frankiewaang)\
**Post date:** [January 24, 2022, 2:39am UTC](https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096/1 "2022-01-24T02:39:57Z")

</div>

Hi Guys,  
Say I have a dataset like this:

```julia
x = DataFrame(a=[1,3,4,5],b=["a;b;c;d","a;c;d","a;c","b;d"])

```

I want to first split the column `b` and then explode it to a long dataset.  
In python the code is like this:

```julia
x['b'] = x['b'].str.split(";")
x.explode('b')

```

Is there any way I could do the same as in python?  
Thanks guys!  
PS: The first step to split the string could be, I am puzzled by the second part

```julia
 select(x,:b=>ByRow(v->split(v,';')))

```

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [January 24, 2022, 2:48am UTC](https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096/2 "2022-01-24T02:48:48Z")

</div>

In your example, how should `x` look like after `x.explode('b')`?

---

<div class="post-metadata">

**Author:** ![Frankiewaang](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@Frankiewaang](https://discourse.julialang.org/u/Frankiewaang)\
**Post date:** [January 24, 2022, 2:51am UTC](https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096/3 "2022-01-24T02:51:37Z")

</div>

It would expand the dataset horizontally, like would have  
1 a  
1 b  
1 c  
1 d  
3 a  
3 c  
3 d  
like this(sorry I am not familiar with markdown table syntax)

---

<div class="post-metadata">

**Author:** ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)\
**Post date:** [January 24, 2022, 4:03am UTC](https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096/4 "2022-01-24T04:03:26Z")

</div>

```julia
x[!,"b2"] = split.(x.b, ";")
flatten(x, "b2")

```

For more info, `?flatten`.

---

<div class="post-metadata">

**Author:** ![Frankiewaang](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@Frankiewaang](https://discourse.julialang.org/u/Frankiewaang)\
**Post date:** [January 24, 2022, 4:06am UTC](https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096/5 "2022-01-24T04:06:22Z")

</div>

Thanks, my man!

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [January 24, 2022, 7:42am UTC](https://discourse.julialang.org/t/is-there-any-function-in-julia-equivalent-to-pandas-explode-function/75096/6 "2022-01-24T07:42:19Z")

</div>

> [@Mattriks](#):
>
> `x[!,"b2"] = split.(x.b, ";")`

or just:

```julia
x.b2 = split.(x.b, ";")

```
