Q 1.1

How many columns are in the title_basics DataFrame? What is the data type of the startYear column? Does this make sense?

Q 1.2

What is the value in 101st row of the primaryTitle column of the title_basics DataFrame? HINT: Recall that DataFrame uses 0-indexing

Q 1.3

Display the first 3 rows and the last 6 rows of the title_basics DataFrame as a single DataFrame.

Q1.4

How many unique titleTypes are there in the title_basics DataFrame? Which is the most common

Q1.5

Remove the originalTitle and endYear columns from the title_basics DataFrame. Make sure that the columns are permanently removed from the title_basics DataFrame

Q1.6

Rename primaryTitle to title and startYear to year in the title_basics DataFrame. Make sure that the changes are reflected permanently in the title_basics DataFrame

Q1.7

A crucial step in most data processing pipelines for machine learning is dealing with missing or corrupted data. Often, these missing values are represented as a NaN (not a number). Sometimes in the context of machine learning we’d want to estimate a value for a missing feature rather than remove that sample point entirely. Can you think of some simple ways in which we could perform that estimation?

使用平均值、中位数、邻近数进行插值处理

Q1.8

Remove all rows from the title_basics DataFrame where runtimeMinutes or year is `NaNo

Q1.9

Change the data type of the year column in the title_basics DataFrame to something that makes more sense. Then confirm that the change is permanently applied.

Let’s practice some more basic filtering and sorting now.

Q1.10

Extract the feature films (titleType == "movie") released in 1954 from the title_basics DataFrame (save this as a new DataFrame, feature_films_1954).

Q1.11

Among the feature films from 1954, which film has the longest runtime? Return its title and runtimeMinutes as a DataFrame extracted from the feature_films_1954 DataFrame.

Q2.1

For each genre in the title_basics DataFrame, compute the mean runtime of feature films released since 1960.

Show the five longest-mean genres.

Q2.2

Merge the title_ratings DataFrame with the title_basics DataFrame by joining on the tconst column. How many titles are present in the title_basics DataFrame but not in the title_ratings DataFrame? Store the merged DataFrame as merged_df. Hint: Recall that because of the genre splitting, the number of titles is not equal to the number of rows.

Q2.3

Using the merged_df DataFrame and plotly express, create an interactive scatter plot of the runtimeMinutes vs. numVotes for movies in the merged_df DataFrame. Color the points by the year of the movie and add a title and axis labels to the plot. Also, make sure the movie title is visible when hovering over the data points. Note: To make the data easier to visualize, we take a sample of just 2000 movies. That’s why you may not see your favorites on this plot. It’s important not to change the random state as you’ll end up getting different results for the following questions.

Part 3: Finding the perfect movie

Aakarsh has spent his whole summer brainrotting and doomscrolling, so now his attention span is COOKED. He wants to pick a movie to watch tonight but wants to make sure it isn’t so long he gets bored. He decides to construct a Brainrot Score (BRS) to help him find the perfect movie: $BRS = \frac{\text{averageRating}}{\sqrt{\text{runtimeMinutes}}}$ He also wants to make sure the following criteria hold: - The title should be a movie made in 1980 or later. - It must have at least 10000 votes. - It must be in the History, Thriller, or Comedy genres. Can you help Aakarsh out by finding the 3 best movies by BRS in each of his preferred genres?