Skip to content

Instantly share code, notes, and snippets.

@FelixChop
Created August 8, 2018 08:21
Show Gist options
  • Select an option

  • Save FelixChop/e8decd1c6d61893b628f68db12be15c0 to your computer and use it in GitHub Desktop.

Select an option

Save FelixChop/e8decd1c6d61893b628f68db12be15c0 to your computer and use it in GitHub Desktop.
column_edge = 'Phone number'
column_ID = 'ID'
data_to_merge = df[[column_ID, column_edge]].dropna(subset=[column_edge]).drop_duplicates() # select columns, remove NaN
# To create connections between people who have the same number,
# join data with itself on the 'ID' column.
data_to_merge = data_to_merge.merge(
data_to_merge[[column_ID, column_edge]].rename(columns={column_ID:column_ID+"_2"}),
on=column_edge
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment