I trying to do a match with the following 2 dataframe:
df_co:
Cntr No Labour Material Amount
BHCU 2604370 0.0 82.5 82.5
BHCU 2604370 24.0 22.0 46.0
df:
Cntr No Total
BHCU 2604370 82.0
BHCU 2604370 46.0
code:
df['Tally'] = ((df_co['Cntr No'].isin(df['Cntr No'])) &
((df_co['Labour'].isin(df['Total'])) |
(df_co['Material'].isin(df['Total'])) |
(df_co['Amount'].isin(df['Total'])))).map({True:'Yes',False:'No'})
It should not give me a match as df_co 'Amount' is 82.5 and df 'Total' amount is 82.00.
But my result give me both matched.
Result:
Cntr No Total Tally
BHCU 2604370 82.0 Yes
BHCU 2604370 46.0 Yes
Suspect the code comparison is wrong.
convert to float:
a = df.iloc[:, :5]
b = df.iloc[:,5:29].apply(lambda x :
x.str.extract('(\d+)',expand=False).astype(float))
c = df.iloc[:, 29:]
df = pd.concat([a,b,c], axis=1)