PANDAS Within Category Normalization I'm want to normalize sales data of multiple point of sales (POS), Products and weeks. The dataframe looks like this:

    pos product sales   week
0   1   car     250      1
1   2   tank    400      2
2   2   car     300      1
3   1   tank    500      2


The goal is to normalize the data between 0,1 for each point of sale and product, e.g the minimum and maximum relate to the minimum and maximum of sales within a specific product and a specific point of sale. I guess I can just create a column for each combination (example below) and then normalize each column but I'm looking for a more elegant solution. 

    pos     1         2
    product car tank  car   tank
week                
1           250  0    300     0
2           0    500    0   400


Thanks, 
Al
As you require it to be per week vs point of sale, you have to group them by those columns. Once grouped, you could run do the standard split-apply-combine, where based on the grouping, you get splits or groups, you can apply a function that normalizes data in this group and then you combine all the groups back.

You can read about it more here : https://pandas.pydata.org/pandas-docs/stable/groupby.html