Pandas Collaboration Analysis: Landing Sources, Top Collaborators, Country Comparison
Company: Notion
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Technical Screen
You have 60 minutes of live coding, in an environment of your choice, to analyze two CSV files with pandas: one describing users and one logging collaboration activity on the pages of a document-editing product. The interviewer asks three questions in turn and probes how you define each metric.
The report names the two files but not their columns. Assume they look like this, and confirm the real columns before coding:
- `users.csv`: one row per user, with `user_id` and `country`.
- `collaboration.csv`: one row per page event, with `user_id`, `page_id`, `event_type` (for example `create`, `edit` or `view`), `landing_source` (the entry point through which the user reached the page, such as a shared link, an invitation email or in-app navigation) and `event_time`.
### Clarifying Questions
- Is `landing_source` recorded on every event, or only on the first event of a visit?
- Does creating a page count as editing it when collaboration is defined?
- Should users in `users.csv` with no activity in `collaboration.csv` enter any denominator?
- Are there bot, deleted or internal test accounts to exclude?
### Part 1 — Landing source distribution
Find the distribution of landing sources, the entry points through which non-creator users reach pages. Be ready to explain whether you computed it at the event level or the user level, and whether highly active users who generate many repeated events bias the result.
```hint Count the heavy user
Imagine one user with 500 events, all through the same entry point, and 50 users with two events each. What does each way of counting say about how users arrive?
```
#### Clarifying Questions for this Part
- Is a non-creator a user who has never created a page, or any user acting on a page someone else created?
- Is the question about how people first arrive, or about where page traffic comes from overall?
#### What This Part Should Cover
- A stated definition of non-creator users and the filter that implements it
- Event-level versus user-level shares, and which one answers the question asked
- Handling of repeated events, missing sources and users who arrive through several sources
### Part 2 — Most frequent collaborator
For each user, find the user they collaborate with most. Define collaboration as two different users having edited the same page. Build the user pairs, deduplicate them, and decide whether collaboration strength is measured by the number of co-edits or by the number of distinct shared pages.
```hint Duplicates multiply
Repeated edits by the same user on the same page multiply when users are paired. Decide which duplicates to remove before forming pairs and which after.
```
```hint One page, many editors
Consider a page edited by hundreds of people. How many pairs does it create, and is each of them really a collaboration?
```
#### What This Part Should Cover
- Pair construction that excludes self-pairs and avoids double counting
- A justified choice of strength measure: distinct shared pages versus co-edit counts
- A deterministic rule for ties, handling of users with no collaborator, and the cost of very large pages
### Part 3 — Cross-country collaboration
Compare how inclined users in different countries are to collaborate. Do not stop at a single number: state the numerator and denominator of each metric you report, such as the share of users who collaborate, shared pages per user, or a collaborative editing rate.
```hint Separate activity from propensity
A country whose users edit more pages will have more shared pages per user even if its users are no more collaborative. Choose denominators with that in mind.
```
#### What This Part Should Cover
- At least two metrics with explicit numerators and denominators, and what each one measures
- Joining country onto the activity data and handling users whose country is unknown
- Whether differences between countries reflect behavior or composition, and how sample size affects the comparison
### What a Strong Answer Covers
- Definitions stated and agreed before code is written
- Correct pandas mechanics: filters, deduplication, a self-join on pages, grouped aggregations and deterministic tie-breaking
- Awareness of how heavy users and very large pages distort counts
- Counts reported beside every rate, so small groups are not over-read
- Clear trade-offs for each metric choice
### Follow-up Questions
- How would you measure collaboration between users in different countries, rather than comparing each country's collaboration rate?
- If two users edit the same page months apart, is that collaboration? How would you add a time window?
- The pair table no longer fits in memory. How would you compute each user's top collaborator?
- One country has a much higher collaborator rate. How would you check whether its mix of accounts, for example team versus individual use, explains the gap?
Overview: A pandas live-coding exercise on user and page-activity files from a collaborative editing product: the landing-source mix of non-creator users, each user's most frequent collaborator, and collaboration propensity by country. It tests metric definitions, deduplication, building user pairs, and choosing numerators and denominators.
Read the full Notion Data Scientist interview experience this question came from