Skip to content

Rapct/Project_linmeng

Repository files navigation

Flight Management System

Description

This project is a Python application designed to manage and analyze passenger data for a fictional airline. It includes functionalities to load, clean, analyze, and visualize data concerning age distributions, loyalty memberships, and travel class distinctions among passengers.

Setup and Installation

Before running this project, make sure you have Python 3.x installed on your machine. The project depends on several Python libraries, including pandas, Matplotlib, Seaborn, and Plotly.

  1. Clone the repository:
    git clone https://github.com/Rapct/Project_linmeng/
  2. Navigate to the project directory:
    cd Project_linmeng
  3. Install the required libraries:
    pip install -r requirements.txt

pandas matplotlib seaborn plotly

Project Structure

  • main.py: The main script responsible for coordinating data loading, cleaning, and visualization functions.
  • passenger_analysis.py: This module contains all functions used for data manipulation and analysis.
  • test_passenger_analysis.py: Contains unit tests for the functions defined in passenger_analysis.py to ensure their correct functionality.

Usage

To run the project, execute the main script from the command line:

python main.py


## Main Functions
load_data(file_path): Loads data from a CSV file into a pandas DataFrame.
clean_data(df): Cleans the DataFrame by handling missing values and ensuring proper data types.
calculate_average_age(df, travel_class): Calculates and returns the average age of passengers within a specified travel class.
find_loyalty_members(df): Identifies and returns a list of loyalty program members.
get_class_statistics(df): Returns a dictionary containing average ages and the number of loyalty members for each travel class.
plot_age_distribution(df): Plots a histogram of the age distribution of all passengers.
plot_average_age_by_class(df): Plots the average age of passengers by travel class using a bar chart.
plot_age_vs_loyalty(df): Plots a scatter plot of age versus loyalty membership status using Seaborn.
plot_age_distribution_by_class(df): Displays the age distribution for each travel class using a box plot with Plotly.

## Visualization Outputs
The visualizations generated by the scripts are saved in the project directory as PNG files:
age_distribution.png
average_age_by_class.png
age_vs_loyalty.png
age_distribution_by_class.png

## Testing
To run the unit tests, use the following command:
python -m unittest test_passenger_analysis.py

## Contributions
To contribute to this project, please create a fork of the repository and propose your changes through a pull request.

## Troubleshooting
Issue: Missing dependencies
   Error: ModuleNotFoundError
   Solution: Make sure all dependencies are installed using:
   pip install -r requirements.txt
Issue: CSV file not found
   Error: FileNotFoundError
   Solution: Check that the passengers.csv file is in the correct directory as specified in main.py.

## Acknowledgments
Thank you to Professor Kumar, student Francis, and the resources ChatGPT that played a significant role in the development of this project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages