group=[:A,:A,:B,:B,:C,:C,:C,:C]
X = 100:108
df = DataFrame(; group, X)
julia> df = DataFrame(; group, X)
8×2 DataFrame
Row │ group X
│ Symbol Int64
─────┼───────────────
1 │ A 101
2 │ A 102
3 │ B 103
4 │ B 104
5 │ C 105
6 │ C 106
7 │ C 107
8 │ C 108
I want to delete the second line that starts with C, so what should I do? I do not want to write thr code like deleteat! (df,6). What I want is that the code should contain C and 2.Thanks for helping me!
julia> deleteat!(df, findall(==(:C), df.group)[2])
7×2 DataFrame
Row │ group X
│ Symbol Int64
─────┼───────────────
1 │ A 101
2 │ A 102
3 │ B 103
4 │ B 104
5 │ C 105
6 │ C 107
7 │ C 108
Assumes that there is a second line that starts with C i.e. assumes there are at least two Cs in the group column.
Thanks.If I want the code to contain C and 106(delete the sixth row in df),what should I do?I found that the function findall didn’t work.Thanks for helping me!