Created
August 8, 2018 08:25
-
-
Save FelixChop/9ebf314ca6903445c48c6ed5341f84af to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # By joining the data with itself, people will have a connection with themselves. | |
| # Remove self connections, to keep only connected people who are different. | |
| d = data_to_merge[~(data_to_merge[column_ID]==data_to_merge[column_ID+"_2"])] \ | |
| .dropna()[[column_ID, column_ID+"_2", column_edge]] | |
| # To avoid counting twice the connections (person 1 connected to person 2 and person 2 connected to person 1) | |
| # we force the first ID to be "lower" then ID_2 | |
| d.drop(d.loc[d[column_ID+"_2"]<d[column_ID]].index.tolist(), inplace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment