export_data()
Exports all processed data to both CSV and Excel formats.Description
Convenience method that calls bothexport_csv_data() and export_excel_data() to generate all output files in a single operation.
Parameters
No parameters required.Returns
No return value.Output Files
Generates two files in the current working directory:- processed_data.csv - Weekly metrics with pipe delimiter
- processed_data.xlsx - Monthly metrics with three sheets (JFK, Regular, Others)
Implementation Details
From source/main.py:146-148Usage Example
Ensure
generate_week_metrics(), generate_month_metrics(), and format_data() have been called before exporting to ensure data is complete and properly formatted.export_csv_data()
Exports weekly aggregated metrics to a CSV file.Description
Writes thecsv_df DataFrame containing weekly metrics to a pipe-delimited CSV file.
Parameters
No parameters required.Returns
No return value.Output File Details
Filename:processed_data.csv
Location: Current working directory
Delimiter: Pipe character (|)
Index: Not included in output
Columns:
Week identifier in ‘YYYY-WWW’ format
Minimum trip time in seconds (rounded to 2 decimals)
Maximum trip time in seconds (rounded to 2 decimals)
Average trip time in seconds (rounded to 2 decimals)
Minimum trip distance in miles (rounded to 2 decimals)
Maximum trip distance in miles (rounded to 2 decimals)
Average trip distance in miles (rounded to 2 decimals)
Minimum trip amount in dollars (rounded to 2 decimals)
Maximum trip amount in dollars (rounded to 2 decimals)
Average trip amount in dollars (rounded to 2 decimals)
Total number of trips for the week
Week-over-week percentage change in total services (rounded to 2 decimals)
Implementation Details
From source/main.py:134-135Example Output
The pipe delimiter (
|) is used instead of comma to avoid conflicts with decimal values and potential commas in data fields.export_excel_data()
Exports monthly metrics to an Excel file with multiple sheets.Description
Writes monthly metrics segmented by rate code type to a multi-sheet Excel workbook. Each rate code category (JFK, Regular, Others) is exported to a separate sheet.Parameters
No parameters required.Returns
No return value.Output File Details
Filename:processed_data.xlsx
Location: Current working directory
Engine: OpenPyXL
Index: Not included in output
Sheets:
- JFK - Metrics for JFK airport trips (RatecodeID = 2)
- Regular - Metrics for standard rate trips (RatecodeID = 1)
- Others - Metrics for all other rate codes
Sheet Structure
All sheets contain the same columns:Month identifier in ‘YYYY-MM’ format
1 for weekdays (Monday-Friday), 2 for weekends (Saturday-Sunday)
Total number of trips for the month and day type
Sum of all trip distances in miles for the month and day type
Sum of all passengers transported for the month and day type
Implementation Details
From source/main.py:138-143Usage Example
Excel Sheet Preview
JFK Sheet Example:| year_month | day_type | services | distances | passengers |
|---|---|---|---|---|
| 2022-01 | 1 | 45623 | 567823.45 | 78934 |
| 2022-01 | 2 | 12456 | 154321.67 | 21543 |
| 2022-02 | 1 | 47821 | 589234.12 | 82341 |
| 2022-02 | 2 | 13124 | 162345.89 | 22678 |
OpenPyXL must be installed in your environment. Install with:
pip install openpyxlEach sheet represents a different rate code category, allowing easy comparison of metrics across trip types and time periods.