Esmee
Esmee

Reputation: 1

assign with for loop products to warehouse, some product have product couple that has to be the same warehouse. How to get corresponding product id

The first part of my code makes sure that the productids with highest loss (if not stored in warehouse 1), are stored in warehouse 1. But then some of this products are in a product couple, which means that they have to be in the same warehouse. I have a dataframe with the two columns, first column is productid and second column is productid2 of the couples. How can I write a code in my loop that finds the corresponding product id, and also do the same actions for the corresponding product id. So "*

if capacityleft >= row["#pickUpBoxes"]:

                warehouse.append("warehouse1")

                capacitysum = capacitysum + (row["#pickUpBoxes"])**


*code*
warehouse = []

capacity = 960.0

capacitysum = 0

for index, row in dfAvgDailyProfitLoss_PickUpBoxes.iterrows():

    capacityleft = capacity - capacitysum

    if capacityleft >= row["#pickUpBoxes"]:

        warehouse.append("warehouse1")

        capacitysum = capacitysum + (row["#pickUpBoxes"])

        for row["product-id"], line in zip(x, y):
            
            if capacityleft >= row["#pickUpBoxes"]:

                warehouse.append("warehouse1")

                capacitysum = capacitysum + (row["#pickUpBoxes"])

    else:

        warehouse.append("warehouse2")

dfAvgDailyProfitLoss_PickUpBoxes["warehouse"] = warehouse
print(dfAvgDailyProfitLoss_PickUpBoxes)

Upvotes: 0

Views: 24

Answers (0)

Related Questions