# Replace Character in a column

**URL:** https://discourse.julialang.org/t/replace-character-in-a-column/27922
**Category:** New to Julia
**Tags:** dataframes
**Created:** [August 24, 2019, 3:39am UTC](https://discourse.julialang.org/t/replace-character-in-a-column/27922 "2019-08-24T03:39:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Nguyen\_HongSon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nguyen_hongson/32/9803_2.png) [@Nguyen\_HongSon](https://discourse.julialang.org/u/Nguyen_HongSon)
#### Post date: [August 24, 2019, 3:39am UTC](https://discourse.julialang.org/t/replace-character-in-a-column/27922/1 "2019-08-24T03:39:11Z")

</div>

Hi everybody,

I am using DataFrames to work with a CVS file. However, the file includes both numbers and characters.  
Then DataFrames defined the columns that have only Number to be “Float64” type, and the columns that have both Numbers and Characters to be “String”.  
The sample of the column as the attached figure.

I need to convert the column assigned as “String” to be “Float64”, but parse(Float64, “String”) does not work.  
I have two questions:

1. How can I remove the row contain text “#VALUE!” in the column, and then convert the remain to Foat64?

2. Is it possible to replace the text “#VALUE!” by the “number” in the closest row? If it is possible, please teach me how to do?

Thanks you very much!

 ![Char%20in%20String](https://global.discourse-cdn.com/julialang/original/3X/8/c/8cfa03c046336765d4c27b520b0ed5d4ea67c15c.png)

---

<div class="post-metadata">

### Author: ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)
#### Post date: [August 24, 2019, 4:06am UTC](https://discourse.julialang.org/t/replace-character-in-a-column/27922/2 "2019-08-24T04:06:04Z")

</div>

i dont use a lot of dataframes, but maybe pre-processioning the CSV could work, replacing #VALUE! by an empty string

---

<div class="post-metadata">

### Author: ![Daniel\_Berge](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Daniel\_Berge](https://discourse.julialang.org/u/Daniel_Berge)
#### Post date: [August 24, 2019, 4:18am UTC](https://discourse.julialang.org/t/replace-character-in-a-column/27922/3 "2019-08-24T04:18:48Z")

</div>

Something like this would work for #1.

`[parse(Float64,x) for x in skipmissing(df[:Loc3]) if x !="#VALUE!"]`

---

<div class="post-metadata">

### Author: ![Nguyen\_HongSon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nguyen_hongson/32/9803_2.png) [@Nguyen\_HongSon](https://discourse.julialang.org/u/Nguyen_HongSon)
#### Post date: [August 24, 2019, 8:41am UTC](https://discourse.julialang.org/t/replace-character-in-a-column/27922/4 "2019-08-24T08:41:16Z")

</div>

Hi Daniel,

Thank you very much!  
It is work!  
But the result is remained only the column [:Loc3] after remove the “#VALUE!”  
How I can keep the other columns in the table with removed on the rows having “#VALUE!”.  
Thank you.

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [August 24, 2019, 11:06am UTC](https://discourse.julialang.org/t/replace-character-in-a-column/27922/5 "2019-08-24T11:06:00Z")

</div>

Use the `missingstring = "#VALUE"` argument when you readd it in with `CSV.read`. Then it’s easy to replace all missing values in your column, e.g. with `ifelse`.
