Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs

Back to Questions

19. Avg Apple Sign-up Gap

easy
AppleApple
senior

What is the average number of days between consecutive Apple user sign-ups, ordering all sign-ups by joined_dt in ascending order? Return a single value named avg_days_between_signups, rounded to 2 decimal places.

apple_users
Column NameType
user_idint64
first_nameobject
last_nameobject
emailobject
countryobject
joined_dtobject
Expected Output Schema
Column NameType
avg_days_between_signupsfloat64

Constraints

  • Return single value column avg_days_between_signups.

  • Order by joined_dt ascending before diff.

  • Round result to 2 decimal places.

Hint 1

Sort the sign-ups by joined_dt ascending before comparing consecutive rows.

Hint 2

Use a windowed difference (e.g., LAG) to compute the gap from each row to the previous signup date.

Hint 3

Convert the time delta to days, ignore the first NULL gap, then take the mean and round to 2 decimals as avg_days_between_signups.

Roles
Data Scientist
Data Analyst
Data Engineer
Companies
AppleApple
Levels
senior
entry
Tags
pandas
datetime
sorting
diff
aggregation
49 people are solving this problem
Python LogoPython Editor
Ln 1, Col 1

Input Arguments

Edit values below to test with custom inputs

You need tolog in/sign upto run or submit