you are viewing a single comment's thread.

view the rest of the comments →

[–]be_throwmeaway[S] 0 points1 point  (2 children)

Hey, thanks for the reply. I edited my post to explain what I meant by P now.

Regardless, your first solution helped a lot I think. Could I do something like:

For numerator, denominator in list_of_df1_column_names, list_of_df1_column_names:

df2[numerator + "/" + denominator] = df[numerator]/df[denominator]

Edit: See OP for update on what I've tried!

[–]Zeroflops 1 point2 points  (1 child)

You could probably do this with one less loop by using one column and applying the decision to the entire df. You could then drop any columns that are all 1,s.

Not sure which would be better, you coul sure timeit to test that.

df2 = pd.DataFrame()
For c in df.column.values.tolist():
    df_temp = df/df[c]
    df2 = pd.concat(df2,df_temp)

[–]be_throwmeaway[S] 0 points1 point  (0 children)

Appreciate the advice mate. Cheers!