1

I have a Data Frame of quantity of sales for each city, each row represent a unique product like this:

 Product_Code           City A   City B   City C   City D   City E      Price/U
          ***             25      24        0        0        0           20
          ***              0       0      100        0        0          100
          ***              0      50        0       20       25           60
          ***             20       0        0        0        0           10 

How can I get the result as one clomun named city with another column named quantity with value counts?

DF I want:

    Product_Code     City      Quantitiy     Price/U
        ***          City A      25          20
        ***          City B      24          20
        ***          City C     100         100
        ***          City B      50          60
        ***          City D      20          60
        ***          City E      25          60
        ***          City A      20          10

I tried multiple different melt configurations, but somehow I am not able to solve this problem.

fati
  • 79
  • 4

0 Answers0