0

My data (df1)

A1 B1 C1 D1 E1  F1  G1
12  8  1  8  12  AB  6
12  10 0  10  12 BC   4  

I want to filter out above data based on all possible combinations below data(df2)

A1  B1 C1  Count
12  10  0   12
12  8   1    8
11  6   1    5
10  8   0    10

My output i need is

for combination

  A1 B1 C1 of 12,10,12 

in data 2 what are the rows in data 1 will match

for

A1 B1 C1 of 12,10,0 

of data 2 2nd row of data 1 will match.I want to list out rows matching all possible combination cases.

I have tried this but want to automate for all combinations in df2 without mentioning each and every time

g=data[(df1.A1 == 12.0)&(df1.B1 == 10)&(df2.C1==0)]

Output needed

A1 B1 C1 Rows having this combination in df1 12 0 10

  • It seems need iner join betwen 2 Dataframes by first 3 columns – jezrael Mar 21 '20 at 06:54
  • data 2 is a subset telling possible combination of A1 B1 C1 in data 1 with the count. – user12985195 Mar 21 '20 at 06:56
  • Not sure if understand, what are input data sample and what is expected output data sample? Better is add expected data sample and also explain it. – jezrael Mar 21 '20 at 06:59
  • In another words `df1` is input, `df2` is output? Or `df1, df2` are inputs and `df3` (cannot see) is output? – jezrael Mar 21 '20 at 07:00
  • sry edited it for much clarity now.Df1 is the first dataframe df2 is the second dataframe. – user12985195 Mar 21 '20 at 07:03
  • Hi i dont want to use merge.I want to automate the process for each combination in df2 i want rows matching for the combination in df1(I have 48000 rows to look over ) if i have 200 plus combinations in df2 i want to find rows matching for each and every combination – user12985195 Mar 21 '20 at 07:07
  • Not understand why cannot use `merge` – jezrael Mar 21 '20 at 07:08
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/210049/discussion-between-user12985195-and-jezrael). – user12985195 Mar 21 '20 at 07:08

0 Answers0