Last active
October 31, 2021 19:06
-
-
Save khuyentran1401/e6361d1e3f25a2a9c52c0507af322d04 to your computer and use it in GitHub Desktop.
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_friends_df(data: pd.DataFrame): | |
"""Get the number of friends for all people in the network""" | |
all_people = list(set(data["person1"]).union(set(data["person2"]))) | |
num_friends = [ | |
{ | |
"person_id": person_id, | |
"num_friends": get_num_friends(data, person_id), | |
"avg_friends_of_friends": round( | |
get_average_friends_of_a_person_friends(data, person_id), 2 | |
), | |
} | |
for person_id in all_people | |
] | |
return pd.DataFrame(num_friends) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment