AnalystPath

Most Connected Co-Author

PandasMediumMid level~10 min

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.

coauthorship
lead_idpartner_idpaper_date
122021-06-03
132021-06-08
232021-06-08
342021-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 coauthorship

Solve 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

Related Pandas questions