Last active
October 31, 2021 19:06
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_num_friends_map(data: pd.DataFrame): | |
"""Get a dictionary of people and their number of friends""" | |
all_people = list(set(data["person1"]).union(set(data["person2"]))) | |
return {name: get_num_friends(friends, name) for name in all_people} | |
def get_num_friends_of_a_person_friends( | |
data: pd.DataFrame, person_id, num_friends_map: dict | |
): | |
friends = get_friends(data, person_id) | |
return [num_friends_map[friend_id] for friend_id in friends] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment