I am trying to transform this long dataframe to the wide dataframe with the following logic, the numbering of the columns is not important, what is important that the format stays this way as then I would need to use it for apriori algorithm. Answer There are many different ways to reshape a pandas data frame from long to wide