In previous sections, we have analyzed the most frequent keywords and phrases without taking into account the time frame. However, a brand can benefit from a temporal dimension and dynamic analysis of the content of posts and comments.
Our goal in this section is to analyze in time series the moments of highest engagement to posts in terms of likes and shares and then see what those posts were about.
Firstly, we convert a string with a date into a datetime object:
df_comments['date'] = df_comments['created_time'].apply(pd.to_datetime)
The next operation transforms the data frame into a time series and creates an index on a datetime object:
df_comments_ts = df_comments.set_index(['date'])
Finally, we subset our data frame to only get the verbatims since the beginning of 2015:
df_comments_ts = df_comments_ts['2015-01-01':]
We have to execute the same operation on our data frame containing the post to be able to make comparisons:
df_posts['date'] = df_posts['created_time...