# Combine(Merge) Columns

**URL:** https://discourse.julialang.org/t/combine-merge-columns/56202
**Category:** New to Julia
**Tags:** dataframes
**Created:** [February 28, 2021, 6:02pm UTC](https://discourse.julialang.org/t/combine-merge-columns/56202 "2021-02-28T18:02:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dbjulia](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@dbjulia](https://discourse.julialang.org/u/dbjulia)
#### Post date: [February 28, 2021, 6:02pm UTC](https://discourse.julialang.org/t/combine-merge-columns/56202/1 "2021-02-28T18:02:50Z")

</div>

Programming & Julia newbie here: I have googled and searched the documentation and tried various ways to do this but I cannot come up with a solution and it seems so simple. Is there a way to combine two columns within a dataframe. See the below example, how could I make a column that would be named “C” and contain A:1 as it first row? The use case for me would be creating an ID column in an datafame that doesn’t contain one. I know there is a issue with A being a string and B being a Int is there a way to overcome that? Thanks in advance.

using DataFrames

df = DataFrame()

df.A = [“A”,“B”,“C”,“D”]

df.B = 1:4

display(df)

4×2 DataFrame  
Row │ A B  
│ String Int64  
─────┼───────────────  
1 │ A 1  
2 │ B 2  
3 │ C 3  
4 │ D 4

---

<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: [February 28, 2021, 6:07pm UTC](https://discourse.julialang.org/t/combine-merge-columns/56202/2 "2021-02-28T18:07:06Z")

</div>

Easiest solution:

```julia
df.C = string.(df.A, ":", df.B)

```

`transform` solution

```julia
transform!(df, [:A, :B] => ByRow((A, B) -> string(A, ":", B)) => :C)

```

DataFramesMeta solution:

```julia
@transform(df, C = string.(:A, ":", :B))

```

---

<div class="post-metadata">

### Author: ![dbjulia](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@dbjulia](https://discourse.julialang.org/u/dbjulia)
#### Post date: [February 28, 2021, 7:16pm UTC](https://discourse.julialang.org/t/combine-merge-columns/56202/3 "2021-02-28T19:16:18Z")

</div>

Thanks, pdeffebach that worked, appreciate the quick and thorough response.
