Reputation: 575
I have two data frames in python:
df1
A B C
1 1 0
1 2 1
0 1 2
. . .
. . .
df2
T W S Y
7 4 5 [1]
8 12 4 [0,7]
10 14 6 [2,3]
I want to go through all rows of df1 and find the observations in df2 with the following characteristics:
(T <= A) and (W > A) and (S == B) and (sum(pd.Series(Y).isin([C])) != 0)
Obviously, using for loop is not efficient but could you please tell me how can I solve my problem? I've heard that I could vectorization technique like Matlab but I'm not sure if we have such technique in python or not.
Upvotes: 0
Views: 115
Reputation: 510
You can do a merge of the two dataframes and filter the result. I am not sure how optimized it will be, but it will do the job faster than python for loops.
Upvotes: 1