I have an excel with three columns, one is the family code, another the product code and the other the price of the product, so I would have something similar to this:
1. Familia Producto Precio
1. -------- --------- --------
1. 1110 Tallarines 0.85
2. 1110 Macarrones 0.68
3. 2220 Helado 4.65
4. ... ... ...
What I want is to set quartiles for the price column based on the family column. That is, for each of my family codes I will have quartiles with different values based on the family considered.
What I have so far is:
df['quintil_precio_articulo'] = pd.qcut(df['precio'], 5, duplicates='drop', labels=False)