%pylab inline
import matplotlib.pylab as pylab
import pandas as pd
import StringIO
import matplotlib.pylab as plt
import numpy as np
pylab.rcParams['figure.figsize'] = 8, 8 # that's default image size for this interactive session
pd.options.display.width = 200
from datetime import datetime, timedelta
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline]. For more information, type 'help(pylab)'.
df = pd.read_fwf('wc.log', colspecs=[(0,14),(15,173)], header=None, parse_dates=[0])
df[0] = pd.to_datetime(df[0])
df
<class 'pandas.core.frame.DataFrame'> Int64Index: 1948 entries, 0 to 1947 Data columns (total 2 columns): 0 1948 non-null values 1 1948 non-null values dtypes: datetime64[ns](1), object(1)
# calls taking more than 1 second
idxs = (df[0].diff() > np.timedelta64(1,'s')).values
df.iloc[idxs.nonzero()[0] - 1]
0 | 1 | |
---|---|---|
390 | 2014-01-19 19:56:05.754720 | read(3, "u|\375i\272h\3308\216\371\370\17\333\... |
742 | 2014-01-19 19:56:12.388820 | read(3, "\352x\351\347<\315-Xb\273\22\275\r\22... |
966 | 2014-01-19 19:56:16.738680 | read(3, "h\215\273U\316xL\f\177[-BE#\356\2D\36... |
1382 | 2014-01-19 19:56:23.086230 | read(3, "8}\204\271i\254\330\313\227\242%]\215... |
1638 | 2014-01-19 19:56:28.103210 | read(3, "\2!\30\275\232\f\26\265\320@\343O\371... |
1670 | 2014-01-19 19:56:29.487310 | read(3, "\226\3442%\240L \203[\327\347\312\365... |
# overall time
print df[0].max()-df[0].min()
0:00:30.884950
df[0].plot()
plt.title('Calls vs timestamp')
plt.ylabel('time (s)')
# y axis max is 35 seconds
<matplotlib.text.Text at 0x7f667d0>