# Inplace mutation of DataFrame column of type Missing

**URL:** https://discourse.julialang.org/t/inplace-mutation-of-dataframe-column-of-type-missing/97109
**Category:** General Usage
**Created:** [April 5, 2023, 10:20am UTC](https://discourse.julialang.org/t/inplace-mutation-of-dataframe-column-of-type-missing/97109 "2023-04-05T10:20:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fchichorro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fchichorro/32/46993_2.png) [@fchichorro](https://discourse.julialang.org/u/fchichorro)
#### Post date: [April 5, 2023, 10:20am UTC](https://discourse.julialang.org/t/inplace-mutation-of-dataframe-column-of-type-missing/97109/1 "2023-04-05T10:20:53Z")

</div>

I am updating a CSV file by loading it as a DataFrame, loading it in memory and replacing values where I need. The minimal version of this dataset looks like this:

```julia
df = CSV.File(IOBuffer("""fruit,count,verifier\napple,2,\norange,1,\npear,3,"""))|> DataFrame

```

```julia
3×3 DataFrame
 Row │ fruit count verifier
     │ String7 Int64 Missing
─────┼──────────────────────────
   1 │ apple 2 missing
   2 │ orange 1 missing
   3 │ pear 3 missing

```

In this example, elements in the `:count` column will be fairly easy to modify:

```julia
df[findfirst(==("apple"), df.fruit), :count] += 1

```

But if I want to modify the value at `:verifier` column:

```julia
df[findfirst(==("apple"), df.fruit), :verifier] = "joe"

```

It does not let me because I cannot assign a `String` value to a column of type `Missing`.

I tried to change the type of the column to `Vector{Union{Missing,String}}`

```julia
 df.verifier .= convert(Vector{Union{Missing,String}}, df.verifier)

```

But the type of the column persists as `Missing`.  
Got any ideas? I guess I could manually set the types of columns when I first load the DataFrame, but I have dozens of columns and do not want to manually set all column types. I think what I am looking after is something like

```julia
function setproperty!(d::DataFrameRow,:c, val; promote=true)

```

But cannot find such function.

---

<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: [April 5, 2023, 10:27am UTC](https://discourse.julialang.org/t/inplace-mutation-of-dataframe-column-of-type-missing/97109/2 "2023-04-05T10:27:18Z")

</div>

`df.verifier = missings(String, nrow(df))`

---

<div class="post-metadata">

### Author: ![fchichorro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fchichorro/32/46993_2.png) [@fchichorro](https://discourse.julialang.org/u/fchichorro)
#### Post date: [April 5, 2023, 10:39am UTC](https://discourse.julialang.org/t/inplace-mutation-of-dataframe-column-of-type-missing/97109/3 "2023-04-05T10:39:06Z")

</div>

Awesome, didn’t know of `missings`. Thank you @bkamins!

---

<div class="post-metadata">

### Author: ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)
#### Post date: [April 5, 2023, 9:15pm UTC](https://discourse.julialang.org/t/inplace-mutation-of-dataframe-column-of-type-missing/97109/4 "2023-04-05T21:15:56Z")

</div>

you could add and remove a dummy row , similarly to the following

```julia
push!(df,("",-1,""),promote=true)
pop!(df)

```
