Pandas offers something specifically meant for this called melt
: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.melt.html
Without a sample of your code I can't give an example that is code specific, but you would have something like this:
id_vars = ['Customer']
var_name = 'Purchase Type'
value_name = 'Value'
melted_df = pf.melt(unmelted_df, id_vars=id_vars, var_name=var_name, value_name=value_name)
As a result, you would get a melted DataFrame
where Purchase 1
, Purchase 2
, etc are attributes of 'Purchase Type' and the value of those original purchases is displayed in Value
.