# String column dataframe: replace for another string built from a substring from each row

**URL:** https://discourse.julialang.org/t/string-column-dataframe-replace-for-another-string-built-from-a-substring-from-each-row/53684
**Category:** Data
**Created:** [January 20, 2021, 8:01pm UTC](https://discourse.julialang.org/t/string-column-dataframe-replace-for-another-string-built-from-a-substring-from-each-row/53684 "2021-01-20T20:01:49Z")
**Posts on this page:** 1
**Showing post:** 2

<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 20, 2021, 8:18pm UTC](https://discourse.julialang.org/t/string-column-dataframe-replace-for-another-string-built-from-a-substring-from-each-row/53684/2 "2021-01-20T20:18:06Z")

</div>

First, please update DataFrames.jl to 0.22 release to get the latest and bug free functionality.

Now regarding your code the simple transformation is (it assumes that DRE contains ONLY ASCII digits):

```julia
transform!(df, :DRE => ByRow(x -> "20"*x[2:3]) => :DRE)

```

or a general solution that correctly handles all UNICODE characters but is a bit verbose:

```julia
transform!(df, :DRE => ByRow(x -> "20"*last(first(x, 3), 2)) => :DRE)

```

---

_[View the full topic](https://discourse.julialang.org/t/string-column-dataframe-replace-for-another-string-built-from-a-substring-from-each-row/53684)._
