Is there a faster way to extract single rows of a dataframe than the filter function

Hi how’s it going, here is the code I’m currently using:

df is a 1 row dataframe.
df2 is a multiple row dataframe

x= filter(row → row[Symbol(‘ID’)][1]==df[Symbol(“ID”)][1], df2])

So essentially I’m trying to do a lookup and find rows in df2 where the row is equal to the “ID” column in df. df is just a one row dataframe.

I’m new to Julia and I know this is probably incredibly inefficient, using 1 row dataframes and what not. Can someone help me?

x = df2[!,:ID] .== df[1,:ID] 
df2[x,:]

A bit more verbose than tbeason’s solution

using Query
res = @from i in df2 begin
@where i.ID == df1[1, :ID]
@select i
@collect DataFrame
end

You should definitely use joins: Joins · DataFrames.jl

1 Like