-
-
Save amankharwal/dcb90204dbb811ed308941ae1996d865 to your computer and use it in GitHub Desktop.
This file contains 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
media_messages_df = df[df['Message'] == '<Media omitted>'] | |
messages_df = df.drop(media_messages_df.index) | |
messages_df['Letter_Count'] = messages_df['Message'].apply(lambda s : len(s)) | |
messages_df['Word_Count'] = messages_df['Message'].apply(lambda s : len(s.split(' '))) | |
messages_df["MessageCount"]=1 | |
l = ["Aman Kharwal", "Sapna"] | |
for i in range(len(l)): | |
# Filtering out messages of particular user | |
req_df= messages_df[messages_df["Author"] == l[i]] | |
# req_df will contain messages of only one particular user | |
print(f'Stats of {l[i]} -') | |
# shape will print number of rows which indirectly means the number of messages | |
print('Messages Sent', req_df.shape[0]) | |
#Word_Count contains of total words in one message. Sum of all words/ Total Messages will yield words per message | |
words_per_message = (np.sum(req_df['Word_Count']))/req_df.shape[0] | |
print('Average Words per message', words_per_message) | |
#media conists of media messages | |
media = media_messages_df[media_messages_df['Author'] == l[i]].shape[0] | |
print('Media Messages Sent', media) | |
# emojis conists of total emojis | |
emojis = sum(req_df['emoji'].str.len()) | |
print('Emojis Sent', emojis) | |
#links consist of total links | |
links = sum(req_df["urlcount"]) | |
print('Links Sent', links) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment