Document communication functions.
parent
669f7cfecb
commit
d218bb1d7c
|
@ -7,4 +7,8 @@
|
||||||
<orderEntry type="jdk" jdkName="Python 3.9 (straw2analysis)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.9 (straw2analysis)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="NUMPY" />
|
||||||
|
<option name="myDocStringFormat" value="NumPy" />
|
||||||
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -7,6 +7,19 @@ from setup import db_engine, session
|
||||||
|
|
||||||
|
|
||||||
def get_call_data(usernames: List) -> pd.DataFrame:
|
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 = (
|
query_calls = (
|
||||||
session.query(Call, Participant.username)
|
session.query(Call, Participant.username)
|
||||||
.filter(Participant.id == Call.participant_id)
|
.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:
|
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 = (
|
contact_counts = (
|
||||||
comm_df["trace"]
|
comm_df["trace"]
|
||||||
.value_counts(sort=True, ascending=False)
|
.value_counts(sort=True, ascending=False)
|
||||||
|
|
Loading…
Reference in New Issue