Notes:
-
Problem Solved: Provides real-time tracking of inventory levels across multiple warehouses, ensuring accurate stock information.
-
Benefits: Businesses can monitor stock levels in real-time, reducing the risk of stockouts and overstocking.
-
Adoption: Integrate this script with existing inventory systems or use it as a standalone tool for smaller operations.
Python Code:
import pandas as pd
class InventoryTracker:
def __init__(self, warehouse_data):
self.warehouse_data = pd.DataFrame(warehouse_data)
def update_inventory(self, warehouse_id, product_id, quantity):
self.warehouse_data.loc[
(self.warehouse_data['WarehouseID'] == warehouse_id) &
(self.warehouse_data['ProductID'] == product_id), 'Quantity'] += quantity
def get_inventory(self):
return self.warehouse_data
# Sample warehouse data
warehouse_data = [
{'WarehouseID': 1, 'ProductID': 'A101', 'Quantity': 100},
{'WarehouseID': 1, 'ProductID': 'B202', 'Quantity': 150},
{'WarehouseID': 2, 'ProductID': 'A101', 'Quantity': 200},
{'WarehouseID': 2, 'ProductID': 'C303', 'Quantity': 50},
]
# Initialize tracker
tracker = InventoryTracker(warehouse_data)
# Update inventory
tracker.update_inventory(1, 'A101', 50)
# Display updated inventory
print(tracker.get_inventory())
No comments:
Post a Comment