{ "cells": [ { "cell_type": "markdown", "id": "4553d762-c2a5-416b-a6af-e31cf10d8060", "metadata": {}, "source": [ "# Movie Madness \n", "\n", "**Description:** \n", "You are a data analyst for a movie streaming service. You have been tasked with analyzing a dataset of movie ratings to determine which genres are the most popular among users. \n", "\n", "The dataset contains the following columns:\n", "- **user_id:** Unique identifier for each user\n", "- **movie_id:** Unique identifier for each movie\n", "- **rating:** Rating given by the user to the movie (on a scale of 1-5)\n", "- **genre:** Genre of the movie (e.g. Action, Comedy, Drama, etc.)\n", "\n", "**Your task is to:** \n", "- Load the dataset into a Pandas DataFrame\n", "- Group the data by genre and calculate the average rating for each genre\n", "- Sort the results in descending order by average rating\n", "\n", "**Data:** \n", "You can use the following sample data to get started: \n", "```\n", "user_id,movie_id,rating,genre\n", "1,101,4,Action\n", "1,102,3,Comedy\n", "2,101,5,Action\n", "2,103,4,Drama\n", "3,102,2,Comedy\n", "3,104,5,Action\n", "```" ] }, { "cell_type": "code", "execution_count": 1, "id": "b06da085-cf53-43fb-ac61-a6e8a247a0cf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python version 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)]\n", "Pandas version 2.2.1\n" ] } ], "source": [ "# import libraries\n", "import pandas as pd\n", "import sys\n", "\n", "print('Python version ' + sys.version)\n", "print('Pandas version ' + pd.__version__)" ] }, { "cell_type": "code", "execution_count": 2, "id": "8e8e4449-e430-4d50-b58a-558545995a8e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | user_id | \n", "movie_id | \n", "rating | \n", "genre | \n", "
|---|---|---|---|---|
| 0 | \n", "1 | \n", "101 | \n", "4 | \n", "Action | \n", "
| 1 | \n", "1 | \n", "102 | \n", "3 | \n", "Comedy | \n", "
| 2 | \n", "2 | \n", "101 | \n", "5 | \n", "Action | \n", "
| 3 | \n", "2 | \n", "103 | \n", "4 | \n", "Drama | \n", "
| 4 | \n", "3 | \n", "102 | \n", "2 | \n", "Comedy | \n", "
| 5 | \n", "3 | \n", "104 | \n", "5 | \n", "Action | \n", "
| \n", " | user_id | \n", "movie_id | \n", "rating | \n", "average_rating | \n", "
|---|---|---|---|---|
| genre | \n", "\n", " | \n", " | \n", " | \n", " |
| Action | \n", "1 | \n", "101 | \n", "4 | \n", "4.666667 | \n", "
| Action | \n", "2 | \n", "101 | \n", "5 | \n", "4.666667 | \n", "
| Action | \n", "3 | \n", "104 | \n", "5 | \n", "4.666667 | \n", "
| Drama | \n", "2 | \n", "103 | \n", "4 | \n", "4.000000 | \n", "
| Comedy | \n", "1 | \n", "102 | \n", "3 | \n", "2.500000 | \n", "
| Comedy | \n", "3 | \n", "102 | \n", "2 | \n", "2.500000 | \n", "
This tutorial was created by HEDARO
" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }