Vectorized “in” function in julia?

前端 未结 5 1253
抹茶落季
抹茶落季 2020-11-28 13:53

I often want to loop over a long array or column of a dataframe, and for each item, see if it is a member of another array. Rather than doing

giant_list =          


        
5条回答
  •  余生分开走
    2020-11-28 14:13

    findin() doesn't give you a boolean mask, but you can easily use it to subset an array/DataFrame for values that are contained in another array:

    julia> giant_list[findin(giant_list, good_letters)]
    1-element Array{String,1}:
     "a"
    

提交回复
热议问题