# DataFrames: hcat

**URL:** <https://discourse.julialang.org/t/dataframes-hcat/43928>\
**Category:** General Usage\
**Tags:** dataframes\
**Created:** [July 29, 2020, 11:12pm UTC](https://discourse.julialang.org/t/dataframes-hcat/43928 "2020-07-29T23:12:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsmith](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bsmith](https://discourse.julialang.org/u/bsmith)\
**Post date:** [July 29, 2020, 11:12pm UTC](https://discourse.julialang.org/t/dataframes-hcat/43928/1 "2020-07-29T23:12:17Z")

</div>

Sorry for the newbie question. I want to do a hcat with a dataframe and an array, such that the column name is the name of the vector (rather than the default ‘X1’):

```julia
df = DataFrame(A = 1:4, B = [2,4,3,5])
newCol = [7,8,9,2]
newdf = hcat(df,newCol)

4×3 DataFrame
│ Row │ A │ B │ x1 │
│ │ Int64 │ Int64 │ Int64 │
├─────┼───────┼───────┼───────┤
│ 1 │ 1 │ 2 │ 7 │
│ 2 │ 2 │ 4 │ 8 │
│ 3 │ 3 │ 3 │ 9 │
│ 4 │ 4 │ 5 │ 2 │

```

How can I get ‘newCol’ as the column name instead of ‘x1’?

thanks!

---

<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:** [July 29, 2020, 11:45pm UTC](https://discourse.julialang.org/t/dataframes-hcat/43928/2 "2020-07-29T23:45:42Z")

</div>

instead of `hcat`, to add a new column, `df.blah = newCol` will do

---

<div class="post-metadata">

**Author:** ![bsmith](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bsmith](https://discourse.julialang.org/u/bsmith)\
**Post date:** [July 30, 2020, 12:56am UTC](https://discourse.julialang.org/t/dataframes-hcat/43928/3 "2020-07-30T00:56:12Z")

</div>

Thanks! Sorry, new to Julia!

---

<div class="post-metadata">

**Author:** ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Post date:** [July 30, 2020, 5:59pm UTC](https://discourse.julialang.org/t/dataframes-hcat/43928/4 "2020-07-30T17:59:51Z")

</div>

Nothing wrong with simple questions! And welcome to the julia discourse @bsmith
