Oct-23-2023, 12:43 AM
Here is my test script updated and working as expected. Just need to replace the "statusResults" dataframe with the dynamically generated one in the main script, but i feel good about this working in production.
# THIS IS TEMPORARY UNTIL MOVED TO REAL SCRIPT(THIS WILL BE THE PING RESULTS BEFORE WRITING TO CSV) statusResults = pd.read_csv("Register_ip_output_20231021_233512.csv",names=['IP', 'Store', 'Register','Status', 'Datetime']) # Compute what % of registers are offline by_store = statusResults.groupby("Store") status = by_store["Status"] report = pd.concat([status.size(), status.sum()], axis=1).reset_index() report.columns = ["Store", "Register Count", "Percentage"] report["Percentage"] = report["Percentage"] / report["Register Count"] * 100 statuscntUp = len(statusResults[statusResults["Status"] == False]) # USED TO CALCULATE NUMBER OF STORES WITH A % OF REGISTERS DOWN percentDown = len(report[report["Percentage"] != 0].index) # RETURNS THE TOTAL NUMBER OF REGISTERS CHECKED RegisterCount = report["Register Count"].sum() # TOTAL CHAIN % OF REGISTERS UP TotalPercentUp = str(int(statuscntUp / RegisterCount * 100)) + "%" # LIST OF STORES FOR DISPLAYING ON SCREEN(FORMATTED) TwentyStores = ','.join(str(v) for v in report[(report["Percentage"] > 20) & (report["Percentage"] < 50)]["Store"].values) # GETS COUNT OF STORES WITH MORE THAN 20% TwentyPercent = len(report[(report["Percentage"] > 20) & (report["Percentage"] < 50)]["Store"].values) # GETS COUNT OF STORES WITH MORE THAN 50% FiftyPercent = len(report[report["Percentage"] >= 50]["Store"].values) # LIST OF STORES FOR DISPLAYING ON SCREEN(FORMATTED) FiftyStores = ','.join(str(v) for v in report[report["Percentage"] >= 50]["Store"].values)