# Question regarding how replace! works:

**URL:** <https://discourse.julialang.org/t/question-regarding-how-replace-works/84109>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 12, 2022, 3:06pm UTC](https://discourse.julialang.org/t/question-regarding-how-replace-works/84109 "2022-07-12T15:06:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Mac\_Donagh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan_mac_donagh/32/31798_2.png) [@Juan\_Mac\_Donagh](https://discourse.julialang.org/u/Juan_Mac_Donagh)\
**Post date:** [July 12, 2022, 3:06pm UTC](https://discourse.julialang.org/t/question-regarding-how-replace-works/84109/1 "2022-07-12T15:06:32Z")

</div>

Hi all, I am having some issues using `replace!` in my DataFrame. I get the following error when trying to change some strings in a column, so when I create a boxplot they are better labeled:

```julia
ArgumentError: string too large (8) to convert to InlineStrings.String7

```

This is the code that I’m using:

```julia
df_A.col_1 .= replace!(df_A.col1, "Amylo" => "Aymloids") 

```

But when I try to use the function with a short string, i.e. `"A"` it works just fine.

I assume that it is a simple problem, but I can’t find why it is happening.

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [July 12, 2022, 3:12pm UTC](https://discourse.julialang.org/t/question-regarding-how-replace-works/84109/2 "2022-07-12T15:12:49Z")

</div>

Likely you read your data in with CSV, which uses these things called `InlineStrings` (as opposed to regular Julia strings) for better performance.

There are a couple of possible fixes. First, you could just stop trying to use the in-place version of `replace!` and go with simply `replace.()`. Alternatively, you can search the CSV.jl docs which I’m almost certain will tell you about a keyword argument allowing you to read the strings in as regular strings. EDIT: It is called `stringtype`, so `stringtype=String` would work.

---

<div class="post-metadata">

**Author:** ![Juan\_Mac\_Donagh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan_mac_donagh/32/31798_2.png) [@Juan\_Mac\_Donagh](https://discourse.julialang.org/u/Juan_Mac_Donagh)\
**Post date:** [July 12, 2022, 3:16pm UTC](https://discourse.julialang.org/t/question-regarding-how-replace-works/84109/3 "2022-07-12T15:16:02Z")

</div>

Oh, I swore I tried with `replace.()`! It worked great, and also thanks for the explication. I will also try using `stringtype`, and read de documentation.

Thanks!

---

<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:** [July 12, 2022, 3:25pm UTC](https://discourse.julialang.org/t/question-regarding-how-replace-works/84109/4 "2022-07-12T15:25:17Z")

</div>

cc @quinnj

One fix for this is to call `df_A.col_1 = string.(df_A.col_1)` to make it a “normal” string type. The current type is an optimization to reduce the memory footprint, make gc easier, and read strings in faster.
