Document communication functions.

communication
junos 2021-04-06 14:32:18 +02:00
parent 669f7cfecb
commit d218bb1d7c
2 changed files with 30 additions and 1 deletions

View File

@ -7,4 +7,8 @@
<orderEntry type="jdk" jdkName="Python 3.9 (straw2analysis)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="NUMPY" />
<option name="myDocStringFormat" value="NumPy" />
</component>
</module>

View File

@ -7,6 +7,19 @@ from setup import db_engine, session
def get_call_data(usernames: List) -> pd.DataFrame:
"""
Read the data from the calls table and return it in a dataframe.
Parameters
----------
usernames: List
A list of usernames to put into the WHERE condition.
Returns
-------
df_calls: pd.DataFrame
A dataframe of call data.
"""
query_calls = (
session.query(Call, Participant.username)
.filter(Participant.id == Call.participant_id)
@ -18,7 +31,19 @@ def get_call_data(usernames: List) -> pd.DataFrame:
def enumerate_contacts(comm_df: pd.DataFrame) -> pd.DataFrame:
"""" Count contacts (callers, senders) and enumerate them by their frequency. """
"""
Count contacts (callers, senders) and enumerate them by their frequency.
Parameters
----------
comm_df: pd.DataFrame
A dataframe of calls or SMSes.
Returns
-------
comm_df: pd.DataFrame
The altered dataframe with the column contact_id, arranged by frequency.
"""
contact_counts = (
comm_df["trace"]
.value_counts(sort=True, ascending=False)