0

This is my first question here so please excuse me if I cannot explain it very clearly or if I make any mistakes in the way I am posting this.

I have two dataframes (df1 and df2) below;

df1:
Type1    Dia
A       10.25
B       10.5

df2: 
Type2   MinDia     MinR       
X        3.4      580.4878     
Y        3.9      665.8537



df2['MinR'] = df2['MinDia'] * 1750 / (VALUE)

I just calculated MinR as an example using the first value under 'Dia' column on 'A' row from df1 (10.25).

I want to use each of the values under 'Dia' column from df1 in the formula above where it says (VALUE) and print all possible combinations and also show the corresponding Type column names (Type1 and Type2) from df1 and df2 under separate columns. The final version of the code should look like this.

df3:
Type1   Type2   MinDia       MinR
A         X       3.4     580.4878
A         Y       3.9     665.8537
B         X       3.4     566.6667
B         Y       3.9     650.0
colidyre
  • 4,170
  • 12
  • 37
  • 53
  • you can search `cross merge`... – Quang Hoang Feb 06 '20 at 20:51
  • Use `df1.assign(tmp=1).merge(df2.assign(tmp=1), on='tmp').drop('tmp', axis=1).filter(regex='Type|Min')` – Chris Adams Feb 06 '20 at 20:54
  • Thanks for the comments. I have searched for Pandas Merging but I maybe I could not apply it properly. df1 has many more rows in my database. I want the program to use all the rows of df1 and calculate each row seperately in df2 with all the df1 values. I will look into Pandas merging more. – Ogün Ünal Feb 07 '20 at 14:00

0 Answers0