0

As shown in below pic i want to make data exactly like this. Sorting data in descending order to show maximum number of sales in pandas

prod_size = pd.DataFrame(dfd.groupby(['ProductID','ColorName','SizeID']).sum()['Sales (Qty)'])

enter image description here

ProductID   ColorName   SizeID  Location Name   District    Opening QTY Sales (Qty) IN QTY  OUT QTY On Hand Qty Transit QTY Total QTY
0   M-KL-0500013    GREY    40  F-7 Shop-Islamabad  Islamabad   1.0 NaN NaN NaN 1.0 0.0 1
1   M-KL-0500013    GREY    40  Baghban Pura Shop-Lahore    Lahore  1.0 NaN NaN NaN 1.0 0.0 1
2   M-KL-0500013    GREY    40  G-9 Shop-Islamabad  Islamabad   2.0 NaN NaN NaN 2.0 0.0 2
3   M-KL-0500013    GREY    40  King Mall Shop-Gujranwala   Gujranwala  2.0 NaN NaN NaN 2.0 1.0 3
4   M-KL-0500013    GREY    40  GT Road Shop-Gujranwala Gujranwala  1.0 NaN NaN NaN 1.0 0.0 1
... ... ... ... ... ... ... ... ... ... ... ... ...

1: https://i.stack.imgur.com/sJKoq.pngenter code here

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
  • 1
    Post a proper title in the title field and put the question in the question field. Post the code, as text, in the question itself – Panagiotis Kanavos Dec 03 '21 at 12:41
  • 2
    Please, check [ask] and edit your question accordingly. Don't post images of code, error, data etc. Post [mre]. Check [how to make good reproducible pandas example](https://stackoverflow.com/q/20109391/4046632) – buran Dec 03 '21 at 12:44
  • 1
    Post the code itself, not images of the code. Images can't be googled or debugged. Post the sample data you want to use to produce that output. Don't make people type your code and data. NOBODY's going to type an entire Excel sheet just to test your code – Panagiotis Kanavos Dec 03 '21 at 12:45
  • Have you tried this `prod_size.sort_values(by='your_column',ascending=False)` ? – Ulewsky Dec 03 '21 at 15:13

0 Answers0