July 2017
Beginner to intermediate
312 pages
7h 27m
English
We define a simple function that helps us to visualize verbatims associated with a keyword. The first argument df requires a data frame containing a column 'message', the second one the number of verbatims to show, and the third one is a keyword:
def print_verbatims(df,nb_verbatim,keyword):
verbatims = df[df['message'].str.contains(keyword)]
for i,text in verbatims.head(nb_verbatim).iterrows():
print(text['message'])
We can do simple searches by using the following syntax:
print_verbatims(df_comments,5,'google')
Read now
Unlock full access