原题链接:https://leetcode.cn/problems/managers-with-at-least-5-direct-reports/description/?envType=study-plan-v2&envId=30-days-of-pandas&lang=pythondata
题目:
id 是此表的主键(具有唯一值的列)。
该表的每一行表示雇员的名字、他们的部门和他们的经理的id。
如果managerId为空,则该员工没有经理。
没有员工会成为自己的管理者。
编写一个解决方案,找出至少有五个直接下属的经理。
以 任意顺序 返回结果表。
import pandas as pd
def find_managers(employee: pd.DataFrame) -> pd.DataFrame:
count_man = employee.groupby('managerId')['id'].count()
redf = employee[employee['id'].isin(count_man[count_man>=5].index)][['name']]
return redf