Add a plot of most frequent contacts.

communication
junos 2021-05-04 17:23:52 +02:00
parent 9301d9ec7f
commit f37e8dc0eb
2 changed files with 367 additions and 72 deletions

File diff suppressed because one or more lines are too long

View File

@ -86,8 +86,8 @@ def enumerate_contacts(comm_df: pd.DataFrame) -> pd.DataFrame:
# In other words, recode the contacts into integers from 0 to n_contacts,
# so that the first one is contacted the most often.
contact_ids = (
contact_counts.groupby("participant_id") # Group again for enummeration.
.cumcount() # Enummerate (count) rows *within* participants.
contact_counts.groupby("participant_id") # Group again for enumeration.
.cumcount() # Enumerate (count) rows *within* participants.
.to_frame("contact_id")
)
contact_counts = contact_counts.join(contact_ids)