First you can do df2 = select(df, [:col1, :col2, :col5]) to get a dataframe with the three columns you want (just calculate the division column before doing the pivoting). Then you can use df3 = unstack(df2, :col1, :col2, :col5) which should lead to the pivoted version you wanted if I understood correctly.
1 Like