0

I want to sum up the values of cells when a specific condition is hit. Out of the following example I am trying to create a new file.

df = pd.DataFrame({'Article': ['Shoe', 'Shirt', 'Shoe', 'Shoe', 'Hat', 'Hoodie'], 'Price': ['7$', '11$', '7$', '7$', '2$', '3$'], 'Stock': [1100, 1463, 500, 400, 60, 18], 'Color': ['white', 'blue', 'white', 'white', 'green', 'black']})

Out of this DataFrame I'd like to create a new file where it sums up all stocks for the articles. I know how to sum up the values, but I'd like to create a new excel file where the stock for the article shoe is 2000 and only 1 row for the article shoe.

Could somebody give me a hand?

FinneX
  • 5
  • 3

0 Answers0