import pandas as pd
# Step 1: Load Excel file
file_path = "[Link]" # Replace with your actual file path
df = pd.read_excel(file_path)
# Step 2: Rename columns for consistency
[Link] = ["Row Label", "Sum of Pax", "Flight Count"]
# Step 3: Initialize variables
results = []
current_date = None
daily_data = []
# Step 4: Iterate through rows
for _, row in [Link]():
if isinstance(row["Row Label"], str): # Detect new date
if current_date and daily_data:
# Find peak by Pax
peak = max(daily_data, key=lambda x: x[1])
[Link]({
"Date": current_date,
"Peak Hour": peak[0],
"Peak Pax": peak[1],
"ATM during Peak Hour": peak[2]
})
current_date = row["Row Label"]
daily_data = []
else:
# Append (hour, pax, flight_count)
daily_data.append((row["Row Label"], row["Sum of Pax"], row["Flight
Count"]))
# Step 5: Process last block
if current_date and daily_data:
peak = max(daily_data, key=lambda x: x[1])
[Link]({
"Date": current_date,
"Peak Hour": peak[0],
"Peak Pax": peak[1],
"ATM during Peak Hour": peak[2]
})
# Step 6: Convert results to DataFrame
peak_df = [Link](results)
# Step 7: Output
print(peak_df)
# Optional: Save to Excel
# peak_df.to_excel("peak_traffic_with_atm.xlsx", index=False)