Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| import random | |
| from faker import Faker | |
| from datetime import timedelta | |
| fake = Faker() | |
| # ----------------------------- | |
| # CONFIG | |
| # ----------------------------- | |
| NUM_RECORDS = 25 | |
| medicine_names = [ | |
| "Paracetamol", "Amoxicillin", "Azithromycin", "Atorvastatin", | |
| "Ibuprofen", "Metformin", "Cetirizine", "Pantoprazole", | |
| "Aspirin", "Cough Syrup", "Vitamin C", "Insulin" | |
| ] | |
| categories = [ | |
| "Analgesic", "Antibiotic", "Antihistamine", | |
| "Cardiac", "Diabetes", "Gastro", "Supplement" | |
| ] | |
| suppliers = [ | |
| "Sun Pharma", "Cipla Ltd.", "Dr. Reddy's", | |
| "Pfizer Inc.", "Abbott India", "Lupin Ltd." | |
| ] | |
| # ----------------------------- | |
| # DATA GENERATION | |
| # ----------------------------- | |
| data = [] | |
| for _ in range(NUM_RECORDS): | |
| medicine = random.choice(medicine_names) | |
| category = random.choice(categories) | |
| supplier = random.choice(suppliers) | |
| purchase_date = fake.date_between(start_date="-2y", end_date="today") | |
| expiry_date = purchase_date + timedelta(days=random.randint(180, 900)) | |
| record = { | |
| "Medicine_Name": medicine, | |
| "Category": category, | |
| "Batch_No": f"{medicine[:3].upper()}-{random.randint(1000,9999)}", | |
| "Stock_Quantity": random.randint(10, 500), | |
| "Monthly_Sales": random.randint(5, 200), | |
| "Expiry_Date": expiry_date, | |
| "Purchase_Date": purchase_date, | |
| "Supplier": supplier | |
| } | |
| data.append(record) | |
| # ----------------------------- | |
| # CREATE DATAFRAME | |
| # ----------------------------- | |
| df = pd.DataFrame(data) | |
| # ----------------------------- | |
| # SAVE TO CSV | |
| # ----------------------------- | |
| df.to_csv("pharmacy_inventory_25.csv", index=False) | |
| print("✅ 10,000 pharmacy inventory records generated successfully!") | |
| print(df.head()) |