Watch time by genre

joins

Watch time by genre

Netflix Pandas Interview Question

Netflix's content team wants to see which genres members spend the most time watching.

Using the viewing_activity and titles DataFrames, return each genre with the total minutes watched as minutes_watched. Sort the rows by minutes_watched, highest first. Assign the answer to result.

Asked of

  • Data Analyst
  • Product Analyst
  • Business Analyst
  • Analytics Engineer
  • Data Scientist

viewing_activityDataFrame16 rows

Column NameType
view_idint64
profile_idint64
title_idint64
countrystr
watch_datestr
minutes_watchedint64

titlesDataFrame6 rows

Column NameType
title_idint64
title_namestr
content_typestr
genrestr
runtime_minutesint64

viewing_activityExample Input

view_idprofile_idtitle_idcountrywatch_dateminutes_watched
110011United States2024-08-01118
210024United States2024-08-0158
310034United States2024-08-0230
410043United States2024-08-0245
510051Brazil2024-08-0260
610066Brazil2024-08-0352
710076Brazil2024-08-0352
810082Brazil2024-08-0392

titlesExample Input

title_idtitle_namecontent_typegenreruntime_minutes
1Midnight HeistMovieThriller118
2Ocean DeepMovieDocumentary92
3Kitchen WarsSeriesReality45
4The Last ColonySeriesSci-Fi58
5Laugh TrackMovieComedy101
6Crown of AshSeriesDrama52

Example Output

genreminutes_watched
Thriller178
Drama104
Documentary92
Sci-Fi88
Reality45

Explanation

In the example, Thriller comes first with 178 minutes: 118 and 60 minutes of Midnight Heist. The Sci-Fi series The Last Colony was watched for 58 and 30 minutes, 88 in total.

The example above is a small slice of the data. Your code runs against the full DataFrames.