Analyze Movie Ratings with Python
Load 100,000+ real movie ratings and visualize insights with pandas.
Introduction
30 Second Summary
Ever scroll through a streaming service wondering which movies are actually worth watching? Behind every "Top Rated" list is a data analysis process making sense of thousands of opinions.
In this project, you will write a Python script that analyzes 100,000+ real movie ratings from actual users. You will produce charts that reveal which movies people genuinely love, how ratings are distributed, and which genres dominate.
What You'll Build
You will run your finished script in the terminal, watch three charts appear one after another, and find image files saved in your project folder that you can share with anyone.
By the end of this project, you'll have:
- A script that answers "What are the highest-rated movies?" with accurate, filtered results backed by thousands of real ratings.
- Three publication-ready charts saved as image files showing rating distributions, top movies, and genre popularity.
- A complete pandas data analysis workflow (load, explore, filter, analyze, visualize) that you can reuse on any CSV dataset.
- Secret Mission: Analyze how movie ratings change over two decades by converting timestamps to dates and plotting trends.
Are there any prerequisites?
None. This guide includes setup instructions for all required tools. You just need a computer with internet access.
Before We Start
Before we dive in, let's lock in what you're about to build and why it matters.
Set Up Your Environment
To analyze movie ratings, you need three things: Python to run your code, the pandas library to load and manipulate data, and matplotlib to turn numbers into visual charts.
In this step, you will set up your workspace, install these libraries, and download the real MovieLens dataset so you have 100,000+ ratings ready to analyze.
In this step, get ready to:
- Set up a project folder in VS Code.
- Install the pandas and matplotlib libraries.
- Download the MovieLens dataset containing 100,000+ real movie ratings.
Create your project folder in VS Code
You need a dedicated folder to keep your script and data files organized. You will create this folder on your Desktop so it is easy to find.
- Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar.
- Type Visual Studio Code and press Enter to open it.
- Open a terminal in VS Code by clicking Terminal in the top menu bar, then New Terminal.
- Move to your Desktop by running this command:
cd ~/Desktop
- Create your project folder by running this command:
mkdir movie-ratings
- Confirm the folder exists by running:
ls
You should see movie-ratings listed in the output.
- Now open this folder as your VS Code workspace. Click File in the top menu bar.
- Click Open Folder.
- Navigate to your Desktop, select the movie-ratings folder, and click Open.
- Open a fresh terminal by clicking Terminal in the top menu bar, then New Terminal.
Your terminal prompt now shows you are inside the movie-ratings folder. All commands you run from here will operate in this folder.
VS Code asked about trusting the folder?
If you see a popup asking whether you trust the authors of the files in this folder, click Yes, I trust the authors. This is your own folder so it is safe to trust.
help me open my project folder in VS Code
Check your Python version and install libraries
Your script needs Python 3.10 or higher to run. You also need two libraries that do not come with Python by default: pandas for data handling and matplotlib for charts.
- Check your Python version by running this command:
python --version
✔️ I see Python 3.10 or higher
Your Python is ready. Move on to installing the libraries below.
ⓧ I see an older version
You have Python installed but need a newer version. Download the latest Python from python.org/downloads.
- Run the installer and check the box labeled Add Python to PATH (Windows) during setup.
- On macOS, the installer adds Python automatically. After installing, close and reopen your VS Code terminal.
- Run python --version again to confirm you see 3.10 or higher.
If python --version still shows the old version, try python3 --version. On macOS, the new install may only respond to python3. If so, use python3 and pip3 for all commands in this project.
ⓧ Command not found
Python is not installed yet. First try running python3 --version in case your system uses that name instead.
If that also fails, download Python from python.org/downloads.
- Run the installer and check the box labeled Add Python to PATH (Windows) during setup.
- On macOS, double-click the .pkg file and follow the prompts.
- Close and reopen your VS Code terminal after installing.
- Run python --version (or python3 --version) to confirm you see 3.10 or higher.
- Install pandas and matplotlib by running:
pip install pandas matplotlib
What does this command do?
pip is Python's package installer. This command downloads and installs two libraries: pandas (for loading and analyzing tabular data) and matplotlib (for creating charts and plots).
Before you continue, confirm both libraries installed correctly. What version numbers do you think will appear?
- Verify the installation by running:
python -c "import pandas; import matplotlib; print(pandas.__version__, matplotlib.__version__)"
You should see two version numbers printed without any errors. The exact numbers depend on when you run this.
Seeing 'No module named' or 'pip not found'?
If pip is not found, try pip3 install pandas matplotlib instead. On some systems, Python 3's installer is called pip3.
If the import command fails with a module error, make sure you ran the install command in the same terminal. Close and reopen your terminal if needed.
help me install pandas and matplotlib
Download the MovieLens dataset
The MovieLens dataset is a collection of 100,836 real movie ratings from 610 users. Your script will download it as a ZIP file and extract the CSV files you need.
- Create a new file called movies.py in your movie-ratings folder. In VS Code, click File, then New File.
- Save the empty file immediately by pressing Cmd+S (macOS) or Ctrl+S (Windows). Name it movies.py.
- Add the following code to movies.py to download and extract the dataset:
import urllib.request
import zipfile
import os
# Dataset URL and local file path
url = "https://files.grouplens.org/datasets/movielens/ml-latest-small.zip"
zip_path = "ml-latest-small.zip"
# Download and extract only if not already present
if not os.path.exists("ml-latest-small"):
print("Downloading MovieLens dataset...")
urllib.request.urlretrieve(url, zip_path)
with zipfile.ZipFile(zip_path, "r") as zip_ref:
zip_ref.extractall(".")
print("Download complete!")
else:
print("Dataset already exists.")
What does this code do?
- urllib.request downloads the ZIP file from the MovieLens website. This is part of Python's standard library so no extra install is needed.
- zipfile extracts the contents of the ZIP into your project folder.
- The if not os.path.exists check means the script only downloads once. If you run it again, it skips the download.
- Save movies.py by pressing Cmd+S (macOS) or Ctrl+S (Windows).
Before you run this, what do you expect to see printed in the terminal?
- Run the script by executing this command in your terminal:
python movies.py
You should see two lines printed:
Downloading MovieLens dataset...
Download complete!
- Confirm the dataset files are on disk by running:
ls ml-latest-small
You should see movies.csv, ratings.csv, and other CSV files listed. These are the real ratings from 610 MovieLens users.
Seeing a connection error or timeout?
The script downloads a 1 MB file from the internet. Make sure you are connected to the internet. If your network blocks the download, try again on a different connection.
If you see a PermissionError, make sure your terminal is inside the movie-ratings folder. Run pwd to check your current location.
help me download the MovieLens dataset
✔️ Awesome, I've got everything!
Great. Double check you have saved movies.py and that the ml-latest-small folder appears in your VS Code Explorer sidebar.
ⓧ I'd like to double check the full code
Here is the complete movies.py file so far. Make sure yours matches exactly:
import urllib.request
import zipfile
import os
url = "https://files.grouplens.org/datasets/movielens/ml-latest-small.zip"
zip_path = "ml-latest-small.zip"
if not os.path.exists("ml-latest-small"):
print("Downloading MovieLens dataset...")
urllib.request.urlretrieve(url, zip_path)
with zipfile.ZipFile(zip_path, "r") as zip_ref:
zip_ref.extractall(".")
print("Download complete!")
else:
print("Dataset already exists.")
Your environment is ready. You have Python, pandas, matplotlib, and 100,000+ real movie ratings sitting in your project folder. Next up, you will load this data and see what is inside it.
Load and Explore the Data
Your environment is set up and the MovieLens dataset is downloaded. Now it's time to actually look at the data.
Before you can answer questions like "which movies do people love most?", you need to load those CSV files into a structure Python can work with. That structure is a pandas DataFrame. It gives you a spreadsheet-like table you can filter, sort, and aggregate with code.
In this step, get ready to:
- Load movie and rating CSV files into pandas DataFrames.
- Explore the data structure, column types, and basic statistics.
Load the CSV files into DataFrames
- In movies.py, add import pandas as pd on a new line directly below import os.
- Below the download section (after the else: block), add the following code to load both CSV files and print a preview of each:
# Load data into DataFrames
movies = pd.read_csv("ml-latest-small/movies.csv")
ratings = pd.read_csv("ml-latest-small/ratings.csv")
# Display first 10 rows of each dataset
print("=== MOVIES ===")
print(movies.head(10))
print(f"\nTotal movies: {len(movies)}")
print("\n=== RATINGS ===")
print(ratings.head(10))
print(f"\nTotal ratings: {len(ratings)}")
What does this code do?
- pd.read_csv() reads a CSV file and converts it into a DataFrame. pandas automatically detects column names from the header row.
- movies.head(10) prints the first 10 rows so you can preview what columns and values exist without flooding your terminal.
- len() returns the total row count, telling you how many movies or ratings the dataset contains.
- Save movies.py.
- Run the script to see your first real data by running:
python movies.py
You should see a table with columns movieId, title, and genres for movies, and userId, movieId, rating, and timestamp for ratings.
Seeing ModuleNotFoundError?
- Make sure you installed pandas in the previous step with pip install pandas matplotlib.
- If you are using a virtual environment, confirm it is activated before running the script.
- Check that the import line reads import pandas as pd exactly, with no typos.
Why am I getting ModuleNotFoundError for pandas?
Explore the shape of your data
You know what columns exist, but you don't yet know the range of rating values or how many unique users contributed. Statistical summaries answer these questions in one line.
- In movies.py, add the following code at the bottom of the file to print summary statistics:
# Statistical summary and column info
print("\n=== RATINGS SUMMARY ===")
print(ratings.describe())
print("\n=== DATA TYPES ===")
print(ratings.info())
What does this code do?
- ratings.describe() calculates count, mean, standard deviation, min, and max for every numeric column. This reveals the rating scale and average rating at a glance.
- ratings.info() prints column names, data types, and non-null value counts directly to the terminal. This helps you spot missing data early.
- Save movies.py.
Before you run this, what do you think the average movie rating will be? Higher than 3.0, or lower?
- Run the script to see the full output including the statistical summary:
python movies.py
You should see 100,836 total ratings printed in the dataset. The describe() output reveals the mean rating is around 3.5, and ratings range from 0.5 to 5.0 on a half-star scale.
What does the summary tell you?
People are generous raters. The average is above the midpoint (2.5), which means most people rate movies positively. The half-star scale (0.5, 1.0, 1.5, ..., 5.0) gives users 10 possible values to choose from, not just 5.
Output looks wrong or truncated?
- If you see ... in the middle of your table, that is pandas abbreviating wide output. The data is still loaded correctly.
- Make sure your new code is below the download section, not inside the if/else block.
- Confirm you have a blank line between the else: block and the new movies = pd.read_csv(...) line.
Why does my pandas output look different from expected?
✔️ Awesome, I've got everything!
Great. Double check you have saved movies.py and your terminal shows movie titles, genres, rating values, and a statistical summary.
ⓧ I'd like to double check the full code
Your movies.py file is now over 30 lines. Scroll through it and confirm these sections are present in order:
- Imports at the top: urllib.request, zipfile, os, and pandas as pd.
- The download/extract section with if not os.path.exists("ml-latest-small"): and the else: block.
- Two pd.read_csv() calls loading movies and ratings.
- Print blocks showing === MOVIES ===, === RATINGS ===, === RATINGS SUMMARY ===, and === DATA TYPES ===.
You have real data loaded and you can see the shape of the dataset. Next up, you will use this data to answer the big question: which movies are the highest rated?
Find the Best Movies (Naive Approach)
You have your data loaded and explored. You know there are 100,836 ratings across thousands of movies.
Now for the interesting question: which movies are the best? The most obvious approach is to calculate the average rating per movie and sort from highest to lowest. Let's try it.
In this step, get ready to:
- Calculate the average rating for every movie in the dataset.
- Display the top 10 highest-rated movies.
- Reveal how many ratings each "top" movie actually has.
Calculate the average rating per movie
The exploration code from the last step gave you a feel for the data shape. Now it's time to start the actual analysis.
- In movies.py, find these two lines at the bottom of your file:
print("\n=== DATA TYPES ===")
print(ratings.info())
- Delete both lines. These were for exploration only. Your file should now end with print(ratings.describe()).
- Add the following code at the bottom of movies.py to group all ratings by movie and calculate each movie's average:
# Find the "best" movies by averaging their ratings
print("\n=== TOP 10 MOVIES (NAIVE) ===")
average_ratings = ratings.groupby("movieId")["rating"].mean()
top_naive = average_ratings.sort_values(ascending=False).head(10).reset_index()
top_naive.columns = ["movieId", "avg_rating"]
top_naive = top_naive.merge(movies[["movieId", "title"]], on="movieId")
print(top_naive[["title", "avg_rating"]].to_string(index=False))
What does this code do?
This code groups all 100,836 ratings by their movie ID, then calculates the average (mean) rating each movie received.
- groupby("movieId")["rating"].mean() creates one average per movie.
- sort_values(ascending=False).head(10) grabs the top 10 highest averages.
- merge() joins the movie titles back in so you can see names instead of just IDs.
- Save movies.py.
- Run your script to see the results:
python movies.py
You should see a "TOP 10 MOVIES (NAIVE)" section at the bottom of your output. The movie titles probably look unfamiliar.
Seeing a NameError or syntax error?
- Make sure the new code is below the print(ratings.describe()) line, not inside the download if/else block.
- Check that you fully deleted the two DATA TYPES lines and did not accidentally remove the ratings.describe() line above them.
- Confirm the quotes around column names are straight quotes, not curly quotes.
Why is my naive top 10 calculation throwing an error?
Reveal the true rating counts
You have a top 10 list, but do you recognize any of those movie titles? Let's investigate how many people actually rated each of these "top" movies.
- Add the following code at the bottom of movies.py to count how many ratings each top movie received:
# Reveal how many ratings each "top" movie actually has
rating_counts = ratings.groupby("movieId")["rating"].count()
top_naive["num_ratings"] = top_naive["movieId"].map(rating_counts)
print("\n=== WITH RATING COUNTS ===")
print(top_naive[["title", "avg_rating", "num_ratings"]].to_string(index=False))
What does this code do?
This counts the total number of ratings per movie, then maps that count onto your top 10 list as a new column. Now you can see not just the average, but how many people contributed to that average.
- Save movies.py.
Before you run this, take a guess. How many ratings do you think each of these top-ranked movies has? Hundreds? Thousands?
- Run your script again:
python movies.py
Look at the "WITH RATING COUNTS" section. Every single "top" movie has only 1 or 2 ratings. A single person gave each film 5 stars and it rocketed to the top of the list.
This is the problem with naive averaging. A movie that one person loved looks "better" than a classic that thousands of people rated 4.5 stars. The results are meaningless without a minimum threshold.
Why does this matter in data analysis?
This is a real-world data pitfall called the "small sample size" problem. Every data professional encounters it. A small number of observations can produce extreme averages that do not reflect reality.
The fix is filtering. By requiring a minimum number of ratings before a movie qualifies for the "best" list, you remove the noise and find movies that many people genuinely love.
✔️ Awesome, I've got everything!
Great. Make sure you have saved movies.py with both the naive top 10 and the rating counts sections.
ⓧ I'd like to double check the full code
Scroll up through your file and confirm these sections appear in order:
- Imports (urllib.request, zipfile, os, pandas) at the top.
- The download/extract block with the if not os.path.exists check.
- Loading both CSVs into movies and ratings DataFrames.
- Print previews (MOVIES, RATINGS, RATINGS SUMMARY).
- The naive top 10 calculation using groupby("movieId")["rating"].mean().
- The rating counts section using groupby("movieId")["rating"].count().
Make sure the DATA TYPES and ratings.info() lines from the previous step are gone. They were for exploration only.
You have proven that simple averaging produces garbage results. Next, you will fix this by filtering out movies with too few ratings to find the genuinely beloved films.
Filter for Meaningful Results
In the last step, you saw the naive approach fall apart. Movies with a single 5-star rating from one person topped the list over genuine classics. The problem is clear: treating a movie with 1 rating the same as a movie with 200 ratings produces misleading results.
The fix is a filter. By requiring a minimum number of ratings before a movie qualifies for the "top" list, you remove the noise and surface movies that many people genuinely love.
In this step, get ready to:
- Filter movies to only those with 50 or more ratings.
- Confirm the top 10 now shows recognizable classic films.
Add the filtered analysis
Your naive code stays in the script so you can compare results. You will add the improved version directly below it.
- In movies.py, scroll to the bottom of the file (after the === WITH RATING COUNTS === print block).
- Add the following filtered analysis code below:
print("\n=== TOP 10 MOVIES (50+ RATINGS) ===")
# Group ratings by movie and calculate both average and count
movie_stats = ratings.groupby("movieId")["rating"].agg(["mean", "count"])
movie_stats.columns = ["avg_rating", "num_ratings"]
# Only keep movies with 50 or more ratings
popular_movies = movie_stats[movie_stats["num_ratings"] >= 50]
# Sort by average rating and take the top 10
top_movies = popular_movies.sort_values("avg_rating", ascending=False).head(10)
top_movies = top_movies.reset_index().merge(movies[["movieId", "title"]], on="movieId")
print(top_movies[["title", "avg_rating", "num_ratings"]].to_string(index=False))
What does this code do?
This code uses the same groupby approach as before, but with a crucial difference.
- .agg(["mean", "count"]) calculates both the average rating AND how many ratings each movie has, all in one step.
- movie_stats[movie_stats["num_ratings"] >= 50] filters out every movie with fewer than 50 ratings. This is the line that eliminates the noise.
- The .merge() at the end joins movie titles back in, so you see names instead of IDs.
Why 50 ratings as the cutoff?
50 is a common threshold in recommendation systems. It is high enough to filter out one-off ratings, but low enough to keep a healthy pool of qualifying movies. You could experiment with 20, 100, or 200 to see how the results shift.
Before you run this, what do you think you will see in the top 10 now that obscure movies are filtered out?
- Save movies.py and run the script:
python movies.py
Scroll to the === TOP 10 MOVIES (50+ RATINGS) === section in the output. You should see well-known classic films like Shawshank Redemption, each backed by 50 or more ratings.
Compare this to the naive list above it. The difference is night and day. Real movies, real consensus.
Not seeing familiar movies in the filtered list?
- Check that your filter line uses >= 50 and not > 50. The difference of one rating can change which movies qualify.
- Make sure movie_stats.columns = ["avg_rating", "num_ratings"] appears right after the .agg() line. Without renaming the columns, the filter on "num_ratings" will throw a KeyError.
- Confirm you added the new code below the naive analysis, not inside it.
Why is my filtered top-10 still showing obscure movies?
✔️ Awesome, I've got everything!
Great. Double check you have saved movies.py and you can see recognizable films in your filtered output.
ⓧ I'd like to double check the full code
Here is the full movies.py as it should look at this point. Scroll up and confirm each section is present in order.
- Imports (urllib.request, zipfile, os, pandas).
- Download and extract section.
- Load data and print exploration output.
- Ratings summary.
- Naive top-10 analysis with rating counts reveal.
- Filtered top-10 analysis (50+ ratings).
Your analysis now surfaces genuinely beloved movies backed by real consensus. Next up, you will turn these numbers into visual charts that make the patterns instantly obvious.
Visualize Your Findings
You have a filtered top-10 list of genuinely well-rated movies backed by real engagement data. Now it's time to turn those terminal numbers into visual charts.
Numbers scrolling through a terminal are hard to interpret at a glance. Charts make patterns obvious instantly and produce shareable image files that tell the story of your analysis.
In this step, get ready to:
- Create a horizontal bar chart of the top 10 highest-rated movies.
- Generate a histogram showing how all 100,000+ ratings are distributed.
- Build a genre popularity chart revealing which genres have the most movies.
Add a horizontal bar chart of the top movies
Your first chart will visualize the top_movies DataFrame you built in the previous step as a horizontal bar chart. matplotlib is the foundational plotting library for Python that all other visualization libraries build on.
- In movies.py, find this import line near the top of your file:
import pandas as pd
- Add the matplotlib import directly below it, so your imports look like this:
import pandas as pd
import matplotlib.pyplot as plt
- Scroll to the very bottom of movies.py and add this chart code after the last print statement:
# Visualization 1: Top movies bar chart
plt.figure(figsize=(10, 6))
plt.barh(top_movies["title"], top_movies["avg_rating"], color="steelblue")
plt.xlabel("Average Rating")
plt.title("Top 10 Highest Rated Movies (50+ ratings)")
plt.xlim(3.5, 5.0)
plt.tight_layout()
plt.savefig("top_movies.png")
plt.show()
What does this code do?
- plt.figure(figsize=(10, 6)) creates a new chart canvas sized at 10 inches wide by 6 inches tall.
- plt.barh() draws a horizontal bar chart. Horizontal bars work well here because movie titles are long and read naturally on the left axis.
- plt.xlim(3.5, 5.0) zooms the x-axis to the 3.5-5.0 range so you can see the differences between highly-rated movies more clearly.
- plt.savefig("top_movies.png") saves the chart as an image file before showing it on screen.
- Save movies.py.
- Run your script to see the first chart appear by running:
python movies.py
A chart window opens showing your top 10 movies as horizontal bars. Close the chart window to let the script finish.
Why does the script pause?
plt.show() blocks script execution until you close the chart window. This is normal behavior. Each time a chart appears, close its window to let the script continue to the next chart or finish.
Don't see a chart window?
- Make sure you saved movies.py before running it.
- Check that import matplotlib.pyplot as plt is at the top of your file, not inside the if block.
- On some systems the chart window may appear behind VS Code. Check your taskbar for a new window.
Why isn't my matplotlib chart showing up?
Add the ratings histogram and genre popularity chart
Your second chart reveals how all 100,000+ ratings are distributed across the 0.5 to 5.0 scale. Your third chart shows which movie genres dominate the dataset.
- In movies.py, add this histogram code below the first chart's plt.show() line:
# Visualization 2: Rating distribution histogram
plt.figure(figsize=(8, 5))
plt.hist(ratings["rating"], bins=[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5],
edgecolor="black", color="steelblue", rwidth=0.8)
plt.xlabel("Rating")
plt.ylabel("Number of Ratings")
plt.title("Distribution of All Movie Ratings")
plt.xticks([1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])
plt.tight_layout()
plt.savefig("rating_distribution.png")
plt.show()
What does this code do?
plt.hist() draws a histogram that counts how many ratings fall into each half-star bin. The bins list defines edges at every 0.5 increment because MovieLens uses a half-star rating scale (0.5, 1.0, 1.5, ..., 5.0).
This chart will show you whether people tend to rate generously or harshly.
- Below the histogram's plt.show() line, add the genre popularity chart:
# Visualization 3: Genre popularity
genres_expanded = movies["genres"].str.split("|").explode()
genre_counts = genres_expanded.value_counts().head(10)
plt.figure(figsize=(10, 6))
plt.bar(genre_counts.index, genre_counts.values, color="steelblue")
plt.xlabel("Genre")
plt.ylabel("Number of Movies")
plt.title("Top 10 Most Common Movie Genres")
plt.xticks(rotation=45, ha="right")
plt.tight_layout()
plt.savefig("genre_popularity.png")
plt.show()
print("\nAnalysis complete! Charts saved as PNG files.")
What does this code do?
Each movie in the dataset has genres stored as a pipe-separated string like Action|Adventure|Comedy. The .str.split("|").explode() call splits each string on the pipe character and expands every genre into its own row.
This lets you count how many movies belong to each genre with .value_counts() and plot the top 10.
- Save movies.py.
Before you run this, what do you think the most common rating value will be in the histogram? And which genre do you expect to be most popular?
- Run your script to see all three charts by running:
python movies.py
Three chart windows appear one after another. Close each window to proceed to the next. After the third chart closes, you should see the message Analysis complete! Charts saved as PNG files. in your terminal.
- Confirm the image files were saved by running:
ls *.png
You should see top_movies.png, rating_distribution.png, and genre_popularity.png listed in the output.
Not seeing all three PNG files?
- Make sure each plt.savefig() call comes BEFORE plt.show() in your code. Calling plt.show() first clears the figure and saves a blank image.
- Check that each chart section starts with its own plt.figure() call. Without it, charts layer on top of each other.
- If you closed a chart window too quickly, the file may still have saved. Open the PNG files in your file browser to check.
Why are my chart images blank or overlapping?
✔️ Awesome, I've got everything!
Great. Double check you have saved movies.py and all three PNG files exist in your movie-ratings folder.
ⓧ I'd like to double check the full code
Your movies.py file is now too long to show in a single block. Scroll through your file and confirm these sections are present in this order:
- Imports: urllib.request, zipfile, os, pandas as pd, matplotlib.pyplot as plt.
- Dataset download block (the if not os.path.exists section).
- Data loading and exploration (movies and ratings DataFrames, head/describe prints).
- Naive top-10 analysis with rating counts.
- Filtered top-10 analysis (50+ ratings).
- Visualization 1: horizontal bar chart with plt.barh(), saved as top_movies.png.
- Visualization 2: histogram with plt.hist(), saved as rating_distribution.png.
- Visualization 3: genre bar chart with plt.bar(), saved as genre_popularity.png.
- Final print statement: Analysis complete! Charts saved as PNG files..
Your analysis script now produces three publication-ready charts from real data. Next up, you will take on a secret mission to unlock time-series analysis by plotting how ratings change over the decades.
Secret mission
Analyze Ratings Over Time
The MovieLens dataset spans over two decades of ratings, from 1996 to 2018. Can you unlock the time dimension hidden in those Unix timestamps and reveal whether people rate movies differently over time?
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely locally, so there are no ongoing costs. Decide whether to keep your files to experiment further, or delete them to free up disk space.
Resources you used:
- The movie-ratings project folder (contains movies.py, chart PNGs, and the downloaded dataset).
- The ml-latest-small dataset folder and ml-latest-small.zip archive (inside movie-ratings).
- Python packages pandas and matplotlib (installed via pip).
Keep everything running
No action needed. Choose this if you want to keep experimenting with the dataset, adding new charts, or tweaking your analysis.
- Your movie-ratings folder stays on your Desktop with all files intact.
- The pandas and matplotlib packages remain installed and available for other Python projects.
Pause - I'll come back to this later
Since this project is entirely local with no running processes, there is nothing to pause. Your files will be waiting for you whenever you return.
- Close the VS Code window to free up memory.
- Your movie-ratings folder and all installed packages remain untouched.
Delete - I don't want to use this again
Remove all project files and uninstall the packages you added.
- Delete the project folder by running this command in your terminal (macOS/Linux):
rm -rf ~/Desktop/movie-ratings
On Windows, run this instead:
rmdir /s /q %USERPROFILE%\Desktop\movie-ratings
- Uninstall the Python packages by running:
pip uninstall pandas matplotlib -y
Keep pandas and matplotlib?
If you plan to do more data analysis in the future, consider keeping pandas and matplotlib installed. They are useful for many Python projects beyond this one.
Nice Work!
Nice Work!
You just built a complete data analysis pipeline that crunches 100,000+ real movie ratings and turns them into visual insights. From raw CSV files to polished charts, you now have firsthand experience with the professional pandas workflow.
You've learned how to:
- Load, explore, and filter real-world data using pandas DataFrames to separate signal from noise.
- Discover why naive averaging produces misleading results and fix it with a minimum-rating threshold.
- Create publication-ready bar charts and histograms using matplotlib that tell a clear story about your data.
- Secret Mission: Analyzed rating trends across two decades by converting Unix timestamps to dates and plotting a time-series line chart.
Ready to quiz yourself?