0% found this document useful (0 votes)
10 views2 pages

Source Code

The document outlines a Python script that processes flight data from an Excel file. It loads the data, renames columns for consistency, and identifies peak passenger hours for each date. Finally, it outputs the results as a DataFrame and includes an option to save the results to a new Excel file.

Uploaded by

Deepthi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Source Code

The document outlines a Python script that processes flight data from an Excel file. It loads the data, renames columns for consistency, and identifies peak passenger hours for each date. Finally, it outputs the results as a DataFrame and includes an option to save the results to a new Excel file.

Uploaded by

Deepthi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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)

You might also like