Created
December 4, 2016 06:09
-
-
Save tdpearson/3ec1ea7d7bfd6f8c59ed8895dfddc644 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
| import pandas as pd | |
| df = pd.DataFrame.from_csv(r"append_test.txt", sep='\t') | |
| frames = [] | |
| for meeting in range(len(df.T)): # iterate over recorded attendances | |
| attendees = df[df.T.iloc[meeting] == 1].index # get attendees for specific meeting | |
| frames.append(pd.DataFrame(index=attendees, columns=attendees).fillna(1)) # create frame from attendees | |
| # sum up jointly attended meetings | |
| pd.concat(frames).fillna(0).groupby(level=0).sum().to_csv(r"jointly_attended.txt", sep='\t') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment