Nov-18-2017, 06:46 PM
I want to select the data from "table" that are exactly matched with the data in "criteria" dataframe.
That is my expected result is;
RowID CusID Area Income
1 1 A 800
5 2 A 1000
import pandas as pd table = pd.DataFrame(data = {'RowID':[1,2,3,4,5,6,7,8,9,10], 'CusID':[1,1,1,1,2,2,3,3,4,4], 'Area':['A','A','A','A','A','A','A','A','B','B'], 'Income':[800,900,1000,900,1000,800,400,400,900,1000],}) criteria = pd.DataFrame(data = {'CusID':[1,2,4], 'Area':['A','A','B'], 'Income':[800,1000,700],})As per the criteria i'm expecting the rows of RowID 1 & 5 only. However according to my code i'm getting RowID 3,6 & 10 also.
That is my expected result is;
RowID CusID Area Income
1 1 A 800
5 2 A 1000
tableMatched= table[(table['CusID'].isin(criteria['CusID'])) & (table['Area'].isin(criteria['Area']))& (table['Income'].isin(criteria['Income']))]Apreciate if someone can help me to code this correctly.