This project analyzes the historical stock prices and quarterly revenue trends of Tesla (TSLA) and GameStop (GME) using Python. It demonstrates data extraction, cleaning, and visualization techniques suitable for financial data analysis.
├── data/
│ ├── processed/
│ │ ├── GME_revenue_clean.csv
│ │ └── TSLA_revenue_clean.csv
│ └── raw/
│ ├── GME_stock_raw.csv
│ └── TSLA_stock_raw.csv
├── notebooks/
│ └── tesla_gme_stock_analysis.ipynb
├── src/
│ ├── __init__.py
│ ├── data_loader.py
│ ├── paths.py
│ └── visualize.py
├── pyproject.toml
└── README.md
Actively maintained and being improved with additional features and analyses.
- Automated data download: Fetches historical stock data from Yahoo Finance using
yfinance. - Web scraping: Extracts and cleans quarterly revenue data from web sources using
pandas.read_html. - Data cleaning: Handles missing values, removes formatting, and ensures numeric types.
- Visualization: Plots stock and revenue trends using Plotly.
- Reproducibility: Saves all processed and raw data to disk for future use.
- Clone the repository and install dependencies (see
pyproject.toml). - Activate your Python environment.
- Run the Jupyter notebook
notebooks/tesla_gme_stock_analysis.ipynbto reproduce the analysis and visualizations.
src/data_loader.py: Functions for downloading, scraping, and cleaning data.src/visualize.py: Functions for plotting stock and revenue trends.src/paths.py: Centralized paths for data directories.
- Stock prices: Yahoo Finance (via
yfinance) - Revenue tables: IBM Skills Network sample project URLs
from src.data_loader import fetch_and_save_stock_data, fetch_clean_revenue_data
tesla_data = fetch_and_save_stock_data("TSLA")
gme_data = fetch_and_save_stock_data("GME")
tesla_revenue = fetch_clean_revenue_data(tesla_url, "TSLA")
gme_revenue = fetch_clean_revenue_data(gme_url, "GME")This project is for educational purposes.