# Split string to multiple columns

**URL:** <https://discourse.julialang.org/t/split-string-to-multiple-columns/26994>\
**Category:** New to Julia\
**Created:** [July 30, 2019, 8:54pm UTC](https://discourse.julialang.org/t/split-string-to-multiple-columns/26994 "2019-07-30T20:54:52Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![rapus95](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rapus95/32/3773_2.png) [@rapus95](https://discourse.julialang.org/u/rapus95)\
**Post date:** [July 30, 2019, 9:50pm UTC](https://discourse.julialang.org/t/split-string-to-multiple-columns/26994/8 "2019-07-30T21:50:04Z")

</div>

Reason why you have multiple columns rather than rows in your dataframe is because the dataframe constructor accepts its inputs column by column (AFAIK for type stability reasons). Using `zip` here was the attempt to merge your data into three columns. Another way to build the DataFrame would be to do it incrementally. For that I recommend looking here:

> [@Adding a new row to a DataFrame](https://discourse.julialang.org/t/adding-a-new-row-to-a-dataframe/1331/4):
>
> Another solution using push!() : julia\> df = DataFrame(A = 1:4, B = ["M", "F", "F", "M"]) 4×2 DataFrames.DataFrame │ Row │ A │ B │ ├─────┼───┼─────┤ │ 1 │ 1 │ "M" │ │ 2 │ 2 │ "F" │ │ 3 │ 3 │ "F" │ │ 4 │ 4 │ "M" │ julia\> push!(df,[6 "F"]) julia\> df 5×2 DataFrames.DataFrame │ Row │ A │ B │ ├─────┼───┼─────┤ │ 1 │ 1 │ "M" │ │ 2 │ 2 │ "F" │ │ 3 │ 3 │ "F" │ │ 4 │ 4 │ "M" │ │ 5 │ 6 │ "F" │

and for size hints to the DataFrame, there:

> <https://stackoverflow.com/questions/28666466/preallocate-a-data-frame-of-known-size-in-julia>

---

_[View the full topic](https://discourse.julialang.org/t/split-string-to-multiple-columns/26994)._
