This project involves setting up a database to store FIFA player data, importing the data into the database, and performing data analysis to generate visualizations and statistics. The project uses Python, Pandas, SQLAlchemy, Matplotlib, and Seaborn to achieve these tasks.
- Python 3.x
- MySQL database server
- Required Python packages: pandas, sqlalchemy, matplotlib, seaborn, pymysql
-
Clone the Repository
git clone https://github.com/your-username/fifa-player-data-analysis.git cd fifa-player-data-analysis
-
Install Required Packages
pip install pandas sqlalchemy matplotlib seaborn pymysql
-
Download CSV Data Download the CSV files from the Kaggle FIFA 23 Complete Player Dataset:
male_players.csv
male_teams.csv
Place these files in the project directory.
-
Database Setup Ensure MySQL is installed and running. Create a database for the project:
CREATE DATABASE fifa;
-
Update Database URI Update the
DB_URI
in bothdata_import.py
andstatistics.py
scripts to match your database credentials:DB_URI = 'mysql+pymysql:https://fifa:fifa@localhost:3306/fifa'
-
Run the Data Import Script
python data_import.py
This script will:
- Connect to the MySQL database.
- Create the necessary tables (
teams
,nationalities
,positions
,players
). - Import data from
male_players.csv
andmale_teams.csv
into these tables.
-
Run the Data Analysis Script
python statistics.py
This script will:
- Connect to the MySQL database.
- Fetch data from the database.
- Clean the data.
- Generate and save visualizations:
- Distribution of Player Overall Ratings
- Average Overall Rating by Player Position
- Top 10 Teams by Average Player Rating
- Top 20 Nationalities by Player Count
The generated plots will be saved as PNG files in the project directory.