PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency with pandas group-wise computations, broadcasting of group aggregates, and DataFrame manipulation without renaming columns.

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

Calculate User Deviation from Team Average Messages

Company: Google

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

usage_stats +---------+---------+---------------+------------+ | user_id | team_id | messages_sent | date | +---------+---------+---------------+------------+ | 1 | 10 | 8 | 2024-05-01 | | 2 | 10 | 3 | 2024-05-01 | | 3 | 20 | 15 | 2024-05-02 | | 4 | 20 | 9 | 2024-05-02 | | 5 | 30 | 0 | 2024-05-03 | +---------+---------+---------------+------------+ ##### Scenario Analyst needs each user’s deviation from their team’s average sent messages without renaming columns in pandas. ##### Question Write Python code that returns a DataFrame with an extra column ‘delta_from_team_mean’ using transform, and explain why transform works better than groupby.mean here. ##### Hints transform broadcasts team means to original index; avoids column aggregation and renaming.

Quick Answer: This question evaluates proficiency with pandas group-wise computations, broadcasting of group aggregates, and DataFrame manipulation without renaming columns.

Last updated: Mar 29, 2026

Loading coding console...

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.

Related Coding Questions

  • Generate binomial matrix and column-normalize - Google (Medium)
  • Analyze video flags and reviews with SQL - Google (Medium)
  • Write SQL/Python for messy event data - Google (Medium)
  • Add a conditional column in Python - Google (Medium)
  • Find most co‑purchased product pairs in SQL - Google (Medium)