Skip to content

Instantly share code, notes, and snippets.

@khuyentran1401
Created August 26, 2021 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save khuyentran1401/51e2f4d2ed0b990924a8063f01101025 to your computer and use it in GitHub Desktop.
Save khuyentran1401/51e2f4d2ed0b990924a8063f01101025 to your computer and use it in GitHub Desktop.
def get_friends(data: pd.DataFrame, person_id):
"""Get friends of a person with specified id"""
return (
data[data["person1"] == person_id]["person2"].values.tolist()
+ data[data["person2"] == person_id]["person1"].values.tolist()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment