Skip to content

Instantly share code, notes, and snippets.

@Abuton
Created September 25, 2021 10:06
Show Gist options
  • Save Abuton/6684a0c1e3f55aaeac61836ff96318a3 to your computer and use it in GitHub Desktop.
Save Abuton/6684a0c1e3f55aaeac61836ff96318a3 to your computer and use it in GitHub Desktop.
def get_total_msg(user:str, df:pd.DataFrame) -> str:
"""
Return the total msgs 'user' has sent
Args:
----
user: the user to extract his/her total count of messages
df: pd.DataFrame: dataframe that stores information about each user and message sent
Returns:
--------
str
"""
try:
if user in df['Sender'].unique().tolist():
text = f"{user} has sent a total message of {len(df[df['Sender'] == user])}"
else: st.info(f"{user} is not present in the data")
except Exception as e : st.warning('error', e)
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment