Movie Data Analysis Project with Python

Data Science project 11

Movie Data Analysis Project with Python

Build a complete movie data analysis workflow with reproducible Python code, traceable calculations, validation checks, and honest limitations.

Explore Data Science training in VizagView all project ideas

Analysis question

How do average ratings, release counts, revenue, and simple profit differ across genre and year?

Dataset

A small embedded catalogue of 12 fictional movies with year, genre, rating, revenue, and budget values.

Requirements

  • Python 3.10 or later
  • A terminal or command prompt
  • python -m pip install pandas
  • About 45-60 minutes to build and review

Method and data checks

Calculate revenue minus budget as a teaching profit field, aggregate rating and profit by genre, aggregate releases and revenue by year, and select the five highest ratings.

  • All titles and commercial figures are fictional
  • Genre counts reconcile to the catalogue
  • Profit is explicitly simplified to revenue minus budget
  • Ratings are not treated as causal drivers of revenue

Complete Python code

Save the program as ds_movie_data_analysis.py. The dataset generator or loader, analysis functions, output, and reproducibility controls are included.

"""Analyse a small, embedded movie catalogue without external downloads."""

from __future__ import annotations

import pandas as pd


def movie_catalogue() -> pd.DataFrame:
    return pd.DataFrame([
        ("Orbit Station", 2019, "Sci-Fi", 7.8, 120, 85), ("Quiet River", 2020, "Drama", 8.1, 18, 12),
        ("City Chase", 2021, "Action", 6.9, 95, 60), ("Paper Planets", 2022, "Animation", 8.3, 140, 72),
        ("Monsoon Cafe", 2023, "Drama", 7.5, 28, 14), ("Signal Lost", 2024, "Sci-Fi", 7.2, 76, 55),
        ("Laugh Track", 2020, "Comedy", 6.7, 44, 22), ("Second Sunrise", 2024, "Drama", 8.0, 52, 26),
        ("Fast Lantern", 2022, "Action", 7.1, 110, 70), ("Tiny Giants", 2023, "Animation", 7.9, 88, 48),
        ("Weekend Fix", 2021, "Comedy", 7.0, 49, 20), ("Red Horizon", 2025, "Sci-Fi", 8.2, 155, 100),
    ], columns=["title", "year", "genre", "rating", "revenue_m", "budget_m"])


def analyse_movies(data: pd.DataFrame) -> dict[str, pd.DataFrame]:
    movies = data.copy()
    movies["profit_m"] = movies["revenue_m"] - movies["budget_m"]
    genre = movies.groupby("genre", as_index=False).agg(films=("title", "size"), average_rating=("rating", "mean"), total_profit_m=("profit_m", "sum")).sort_values("average_rating", ascending=False)
    yearly = movies.groupby("year", as_index=False).agg(releases=("title", "size"), median_rating=("rating", "median"), total_revenue_m=("revenue_m", "sum"))
    return {"genre": genre, "yearly": yearly, "top_rated": movies.nlargest(5, "rating")[["title", "genre", "rating"]]}


def main() -> None:
    result = analyse_movies(movie_catalogue())
    print("By genre:\n", result["genre"].round(2).to_string(index=False))
    print("\nTop rated:\n", result["top_rated"].to_string(index=False))
    print("Catalogue, titles, budgets, and revenues are synthetic teaching examples.")


if __name__ == "__main__":
    main()

Run the project

  1. Create and activate a virtual environment.
  2. Install dependencies with python -m pip install pandas.
  3. Run python ds_movie_data_analysis.py.
  4. Reconcile row counts and totals before interpreting patterns.
  5. Read the limitations before substituting any real dataset.

Expected analytical output

Genre summaries, yearly summaries, calculated profit, and a top-rated table.

Interpretation and responsible-use limits

The sample is synthetic and too small for industry conclusions. Real film profitability involves distribution, marketing, revenue shares, timing, currency, and licensing definitions.

Ways to extend the project

Load a licensed movie dataset, normalise currencies and release dates, split genres carefully, add vote counts, and test whether apparent patterns survive uncertainty checks.

Continue learning Data Science

Try the next project, return to the Softenant project library, or explore the Data Science course in Vizag for guided data cleaning, analysis, visualisation, and portfolio feedback.