I have a standard dataframe template df1:
a = [['100', '20', '20'], ['150', '60', '80'], ['200', '100', '100'],['500', '50', '100']]
df1 = pd.DataFrame(a, columns=['A', 'B', 'C'])
df1
Out[50]:
A B C
0 100 20 20
1 150 60 80
2 200 100 100
3 500 50 100
and my dataset df2
b = [['180.5', '60.3', '20.2'], ['40.2', '2.2', '33.9'], ['205', '100', '100'],['455', '20', '88'],['100', '60', '130'],['10', '10', '10'],['300.64', '66.4', '29.4']]
df2 = pd.DataFrame(b, columns=['A1', 'B1', 'C1'])
df2
A1 B1 C1
0 180.5 60.3 20.2
1 40.2 2.2 33.9
2 205 100 100
3 455 20 88
4 100 60 130
5 10 10 10
6 300.64 66.4 29.4
I want to iterate value of A1,B1,C1 of df2 against all simultaneous values of df1 and append only that set of values to my df2 where all 3 conditions are satisfied (A1<=A, B1<=B, C1<=C).
If the conditions are satisfied for multiple rows in df1, then I will just need the first set of standard value.
This may be considered as checking if all 3 dimensions are within any available standard dimension template.
Expected Output for my dataset df2:
A1 B1 C1 A B C
0 180.5 60.3 20.2 200.0 100.0 100.0
1 40.2 2.2 33.9 150.0 60.0 80.0
2 205 100 100 NaN NaN NaN
3 455 20 88 500.0 50.0 100.0
4 100 60 130 NaN NaN NaN
5 10 10 10 100.0 20.0 20.0
6 300.64 66.4 29.4 NaN NaN NaN
Could not find any suitable solution. I tried with lists but could not come any closer.