# How to delete several rows from a dataframe in one command

**URL:** https://discourse.julialang.org/t/how-to-delete-several-rows-from-a-dataframe-in-one-command/96575
**Category:** New to Julia
**Tags:** dataframes
**Created:** [March 24, 2023, 6:40pm UTC](https://discourse.julialang.org/t/how-to-delete-several-rows-from-a-dataframe-in-one-command/96575 "2023-03-24T18:40:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![CvR](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CvR](https://discourse.julialang.org/u/CvR)
#### Post date: [March 24, 2023, 6:40pm UTC](https://discourse.julialang.org/t/how-to-delete-several-rows-from-a-dataframe-in-one-command/96575/1 "2023-03-24T18:40:35Z")

</div>

Hi,

I would like to delete several rows from a dataframe in one command. For example:

```julia
deleteat!(df, [row1, row2, row3])

```

Where row(n) is a variable and is given by the user. I can delete one row with readline():

```julia
if choice == "3"
print("\033c")
println("Which row to delete?")
dr = readline()
deleteat!(df, parse(Int64,dr))
CSV.write("FILE.csv", df)
println("Data deleted...")
println(df)
println("\n")
end

```

I tried nearly everything to delete multiple rows at once in one command, but without succes.  
Is this possible in Julia?

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [March 24, 2023, 7:24pm UTC](https://discourse.julialang.org/t/how-to-delete-several-rows-from-a-dataframe-in-one-command/96575/2 "2023-03-24T19:24:15Z")

</div>

I think, from what you posted, that your trouble is that you need to parse multiple input rows as an array, which you can do by broadcasting `parse` (with a dot):

```julia
julia> rows = readline()
1 2 3
"1 2 3"

julia> rows
"1 2 3"

julia> parse.(Int, split(rows))
3-element Vector{Int64}:
 1
 2
 3

julia> df = DataFrame(A = 1:5, B = 6:10)
5×2 DataFrame
 Row │ A B     
     │ Int64 Int64 
─────┼──────────────
   1 │ 1 6
   2 │ 2 7
   3 │ 3 8
   4 │ 4 9
   5 │ 5 10

julia> deleteat!(df, parse.(Int, split(rows)))
2×2 DataFrame
 Row │ A B     
     │ Int64 Int64 
─────┼──────────────
   1 │ 4 9
   2 │ 5 10

```

---

<div class="post-metadata">

### Author: ![CvR](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CvR](https://discourse.julialang.org/u/CvR)
#### Post date: [March 25, 2023, 8:50am UTC](https://discourse.julialang.org/t/how-to-delete-several-rows-from-a-dataframe-in-one-command/96575/3 "2023-03-25T08:50:05Z")

</div>

Thank you lmiq, that did the trick! I didn’t realize i had to put a “dot” after “parse”. I searched for half a day but didn’t realize that this was solution for my case. I will dive a bit more into the dot operator know ;-).
