How to Remove Specific Rows from a DataFrame in Julia
Overview
When indexing, you can use the Not() function1. If you input the symbol of the column name as is, or an array of symbols, those columns are excluded from the indexing.
Code
using DataFrames
WJSN = DataFrame(
    member = ["다영","다원","루다","소정","수빈","연정","주연","지연","진숙","현정"],
    birth = [99,97,97,95,96,99,98,95,99,94],
    height = [161,167,157,166,159,165,172,163,162,165],
    unit = ["쪼꼬미","메보즈","쪼꼬미","더블랙","쪼꼬미","메보즈","더블랙","더블랙","쪼꼬미","더블랙"]
)
Let’s run the example code above and check the results.
julia> WJSN
10×4 DataFrame
 Row │ member  birth  height  unit   
     │ String  Int64  Int64   String 
─────┼───────────────────────────────
   1 │ 현정       94     165  더블랙
   2 │ 소정       95     166  더블랙
   3 │ 지연       95     163  더블랙
   4 │ 수빈       96     159  쪼꼬미
   5 │ 다원       97     167  메보즈
   6 │ 루다       97     157  쪼꼬미
   7 │ 주연       98     172  더블랙
   8 │ 다영       99     161  쪼꼬미
   9 │ 연정       99     165  메보즈
  10 │ 진숙       99     162  쪼꼬미
The WJSN dataframe is as shown above.
julia> WJSN[:,Not(:height)]
10×3 DataFrame
 Row │ member  birth  unit   
     │ String  Int64  String 
─────┼───────────────────────
   1 │ 다영       99  쪼꼬미
   2 │ 다원       97  메보즈
   3 │ 루다       97  쪼꼬미
   4 │ 소정       95  더블랙
   5 │ 수빈       96  쪼꼬미
   6 │ 연정       99  메보즈
   7 │ 주연       98  더블랙
   8 │ 지연       95  더블랙
   9 │ 진숙       99  쪼꼬미
  10 │ 현정       94  더블랙
Only :height went in, so the :height column was removed.
julia> WJSN[:,Not([:birth, :unit])]
10×2 DataFrame
 Row │ member  height 
     │ String  Int64  
─────┼────────────────
   1 │ 다영       161
   2 │ 다원       167
   3 │ 루다       157
   4 │ 소정       166
   5 │ 수빈       159
   6 │ 연정       165
   7 │ 주연       172
   8 │ 지연       163
   9 │ 진숙       162
  10 │ 현정       165
The array of symbols [:birth, :unit] went in, so the :birth and :unit columns were removed.
Environment
- OS: Windows
 - julia: v1.6.3
 
