In [1]:
    
from __future__ import print_function
import sys
import numpy as np
sys.path.append('../')
    
In [2]:
    
import whatstk.parser as wp
import whatstk.vis as wv
    
In [3]:
    
#chat = wp.WhatsAppChat("../chats/samplechat.txt")
chat = wp.WhatsAppChat("../chats/samplechat.txt")
    
In [4]:
    
# Dataframe containing the cummulative number of user interventions per day (only days of chat activity are considered)
interventions_day = wp.user_interventions(chat, 'days', length=True)
interventions_day_cum = np.cumsum(interventions_day)
    
In [5]:
    
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['figure.figsize'] = (20.0, 10.0)
wv.temporal_data(interventions_day_cum, "Cummulative number of interventions")
    
    
    
Now let us take a look at the distribution of the length of the interventions of each user. This can give us some insights about which users tend to send out longer (shorter) messages.
In [6]:
    
hist = wp.histogram_intervention_length(chat)
    
In [7]:
    
import seaborn as sns
sns.set_style("whitegrid")
ax = sns.violinplot(x="user", y="length", data=hist)
plt.ylim(-10, 100)
plt.show()