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
1           250  0    300     0
2           0    500    0   400

Thanks, Al


1 Answer 1


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

  • $\begingroup$ Hi Nischal, Thanks for your help. I'm rather new in the field and find it hard to understand. Can you focus me please? $\endgroup$
    – Almog
    Nov 5, 2018 at 17:10
  • $\begingroup$ He provided a link that is helpful - maybe start there and "get back" to us with questions? $\endgroup$ Dec 5, 2018 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.