Most Connected Co-Author
Problem
DataFrame: `coauthorship` (`coauthorship.csv`)
```text
+------------+--------+
| Column | Type |
+------------+--------+
| lead_id | int |
| partner_id | int |
| paper_date | object |
+------------+--------+
(lead_id, partner_id) is unique.
```
Each row means `lead_id` and `partner_id` co-authored a paper together, so **both** researchers gain one collaboration link. Find the researcher who has the most collaboration links. The test data guarantees exactly one such researcher.
Return that researcher's id as `researcher_id` and their number of links as `links`.
Input data
Example rows — the live problem includes the full dataset.
| lead_id | partner_id | paper_date |
|---|---|---|
| 1 | 2 | 2021-06-03 |
| 1 | 3 | 2021-06-08 |
| 2 | 3 | 2021-06-08 |
| 3 | 4 | 2021-06-09 |
Expected output
Your answer should return 1 row with the columns researcher_id, links.
Starter code (Pandas (Python))
import pandas as pd
def top_coauthor(coauthorship: pd.DataFrame) -> pd.DataFrame:
# Your code here
return coauthorshipSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock