PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/Pinterest

Find top category by video time spent

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in pandas-based data manipulation and aggregation, testing competencies in data cleaning, normalization, mapping, filtering, and computing summary statistics.

  • Medium
  • Pinterest
  • Data Manipulation (SQL/Python)
  • Data Scientist

Find top category by video time spent

Company: Pinterest

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Pandas required. You are given a DataFrame df with columns: user_id (int), pin_id (int), pin_type (str), category (str or None), time_spent_sec (numeric). Goal: among video pins, find the canonical category with the highest average time_spent_sec. Requirements: - Consider pin_type values case-insensitively and treat 'vedio' as 'video' (data quality issue). - Normalize category by lowercasing and stripping whitespace, then map via category_map; if a key is missing after normalization or category is null/empty, map to 'unknown'. - Exclude rows where time_spent_sec is null or non-positive. - Return a two-field result: top_category (str), avg_time_spent_sec (float, rounded to 2 decimals). Example inputs category_map = { 'home': 'lifestyle', 'food & drink': 'food', 'recipe': 'food', 'travel': 'travel' } df (illustrative rows) user_id | pin_id | pin_type | category | time_spent_sec 1 | 10 | 'video' | 'Food & Drink' | 120 2 | 11 | 'video' | None | 200 3 | 12 | 'static' | 'Home' | 90 4 | 13 | 'video' | 'Recipe' | 240 5 | 14 | 'video' | 'DIY' | 180 6 | 15 | 'vedio' | 'food & drink ' | 60 What is the top_category and its average time among video pins after mapping and cleaning?

Quick Answer: This question evaluates proficiency in pandas-based data manipulation and aggregation, testing competencies in data cleaning, normalization, mapping, filtering, and computing summary statistics.

Related Interview Questions

  • Write Queries for Pinterest Engagement Tasks - Pinterest (medium)
  • Write SQL for top categories and highly active users - Pinterest (easy)
  • Compute percent of first-cancelled users who never rebook - Pinterest (medium)
  • Compute percent of first-cancel users who never return - Pinterest (easy)
  • Write SQL to compute max-overlap lists - Pinterest (Medium)
Pinterest logo
Pinterest
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
5
0

Pandas required. You are given a DataFrame df with columns: user_id (int), pin_id (int), pin_type (str), category (str or None), time_spent_sec (numeric). Goal: among video pins, find the canonical category with the highest average time_spent_sec. Requirements:

  • Consider pin_type values case-insensitively and treat 'vedio' as 'video' (data quality issue).
  • Normalize category by lowercasing and stripping whitespace, then map via category_map; if a key is missing after normalization or category is null/empty, map to 'unknown'.
  • Exclude rows where time_spent_sec is null or non-positive.
  • Return a two-field result: top_category (str), avg_time_spent_sec (float, rounded to 2 decimals).

Example inputs category_map = { 'home': 'lifestyle', 'food & drink': 'food', 'recipe': 'food', 'travel': 'travel' }

df (illustrative rows) user_id | pin_id | pin_type | category | time_spent_sec 1 | 10 | 'video' | 'Food & Drink' | 120 2 | 11 | 'video' | None | 200 3 | 12 | 'static' | 'Home' | 90 4 | 13 | 'video' | 'Recipe' | 240 5 | 14 | 'video' | 'DIY' | 180 6 | 15 | 'vedio' | 'food & drink ' | 60

What is the top_category and its average time among video pins after mapping and cleaning?

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Pinterest•More Data Scientist•Pinterest Data Scientist•Pinterest Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.