In [1]:
# Import all libraries needed for the tutorial

# General syntax to import specific functions in a library:
##from (library) import (specific library function)
from pandas import DataFrame, read_csv

# General syntax to import a library but no functions:
##import (library) as (give the library a nickname/alias)
import matplotlib.pyplot as plt
import pandas as pd #only needed to determine version number

import glob
from scipy import randn
from pandas import *

# Enable inline plotting
%matplotlib inline

In [2]:
path =r'/analysis'
allFiles = glob.glob("*.txt")
frame = pd.DataFrame()
list = []
for files in allFiles:
    df = pd.read_csv(files,index_col=0, header=0, delimiter="\t")
    list.append(df)
frame = pd.concat(list)
glued = pd.concat(list, axis=1)

#print(frame)

#print(glued)
#print(glued.groupby(level=0, axis=1).std())
stdtab = glued.groupby(level=0, axis=1).std()
meantab = glued.groupby(level=0, axis=1).mean()
#glued.groupby(level=0, axis=1).mean().to_csv("glued.txt", sep="\t")

#plt.figure(figsize=(10, 8), dpi=120);
#meantab.plot(yerr=stdtab)

#dff = pd.concat([meantab, stdtab], axis=1)

#plt.figure(figsize=(10, 8), dpi=120);
#dff.plot()

#plt.figure(figsize=(10, 8), dpi=120);
#bp = frame.boxplot(column=['# Clock'])
#plt.figure(figsize=(10, 8), dpi=120);
#bp = frame.boxplot(column=['In Chain'])
#plt.figure(figsize=(10, 8), dpi=120);
#bp = frame.boxplot(column=['On Target'])

In [3]:
meantab


Out[3]:
In Chain On Target
# Clock
1 0.00 0
2 0.00 0
3 0.00 0
4 0.00 0
5 0.00 0
6 0.00 0
7 0.00 0
8 0.00 0
9 0.00 0
10 0.00 0
11 0.00 0
12 0.00 0
13 0.00 0
14 0.01 0
15 0.01 0
16 0.02 0
17 0.02 0
18 0.02 0
19 0.03 0
20 0.03 0
21 0.03 0
22 0.05 0
23 0.05 0
24 0.07 0
25 0.08 0
26 0.09 0
27 0.10 0
28 0.11 0
29 0.12 0
30 0.13 0
31 0.14 0
32 0.16 0
33 0.18 0
34 0.19 0
35 0.20 0
36 0.22 0
37 0.24 0
38 0.25 0
39 0.28 0
40 0.34 0
41 0.37 0
42 0.43 0
43 0.49 0
44 0.54 0
45 0.56 0
46 0.60 0
47 0.63 0
48 0.65 0
49 0.69 0
50 0.73 0
51 0.79 0
52 0.83 0
53 0.86 0
54 0.90 0
55 0.94 0
56 0.97 0
57 1.01 0
58 1.03 0
59 1.13 0
60 1.15 0
... ...

8659 rows × 2 columns


In [4]:
stdtab


Out[4]:
In Chain On Target
# Clock
1 0.000000 0
2 0.000000 0
3 0.000000 0
4 0.000000 0
5 0.000000 0
6 0.000000 0
7 0.000000 0
8 0.000000 0
9 0.000000 0
10 0.000000 0
11 0.000000 0
12 0.000000 0
13 0.000000 0
14 0.100000 0
15 0.100000 0
16 0.140705 0
17 0.140705 0
18 0.140705 0
19 0.171447 0
20 0.171447 0
21 0.171447 0
22 0.219043 0
23 0.219043 0
24 0.256432 0
25 0.272660 0
26 0.287623 0
27 0.301511 0
28 0.314466 0
29 0.326599 0
30 0.337998 0
31 0.348735 0
32 0.368453 0
33 0.386123 0
34 0.419114 0
35 0.426401 0
36 0.439927 0
37 0.473969 0
38 0.479372 0
39 0.514045 0
40 0.554504 0
41 0.580056 0
42 0.685418 0
43 0.745288 0
44 0.809290 0
45 0.832666 0
46 0.887625 0
47 0.917341 0
48 0.946818 0
49 0.960797 0
50 0.993463 0
51 1.027845 0
52 1.054619 0
53 1.091936 0
54 1.087115 0
55 1.117537 0
56 1.114233 0
57 1.167705 0
58 1.175980 0
59 1.219828 0
60 1.242147 0
... ...

8659 rows × 2 columns


In [21]:
fig, ax = plt.subplots()
meantab.plot(kind='bar',ax=ax, yerr=glued.groupby(level=0, axis=1).std())


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-9d1524b451ae> in <module>()
      1 fig, ax = plt.subplots()
----> 2 meantab.plot(kind='bar',ax=ax, yerr=glued.groupby(level=0, axis=1).std())

/Users/fabianeidens/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in plot_frame(frame, x, y, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, style, title, xlim, ylim, logx, logy, xticks, yticks, kind, sort_columns, fontsize, secondary_y, **kwds)
   1733                              secondary_y=secondary_y, **kwds)
   1734 
-> 1735     plot_obj.generate()
   1736     plot_obj.draw()
   1737     if subplots:

/Users/fabianeidens/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in generate(self)
    903         self._compute_plot_data()
    904         self._setup_subplots()
--> 905         self._make_plot()
    906         self._post_plot_logic()
    907         self._adorn_subplots()

/Users/fabianeidens/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _make_plot(self)
   1559             else:
   1560                 rect = bar_f(ax, self.ax_pos + i * 0.75 / K, y, 0.75 / K,
-> 1561                              start=start, label=label, **kwds)
   1562             rects.append(rect)
   1563             if self.mark_right:

/Users/fabianeidens/anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in f(ax, x, y, w, start, **kwds)
   1506         if self.kind == 'bar':
   1507             def f(ax, x, y, w, start=None, **kwds):
-> 1508                 return ax.bar(x, y, w, bottom=start,log=self.log, **kwds)
   1509         elif self.kind == 'barh':
   1510             def f(ax, x, y, w, start=None, log=self.log, **kwds):

/Users/fabianeidens/anaconda/lib/python2.7/site-packages/matplotlib/axes.pyc in bar(self, left, height, width, bottom, **kwargs)
   5073             errorbar = self.errorbar(x, y,
   5074                                      yerr=yerr, xerr=xerr,
-> 5075                                      fmt=None, **error_kw)
   5076         else:
   5077             errorbar = None

/Users/fabianeidens/anaconda/lib/python2.7/site-packages/matplotlib/axes.pyc in errorbar(self, x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, **kwargs)
   5756                 # using list comps rather than arrays to preserve units
   5757                 lower = [thisy - thiserr for (thisy, thiserr)
-> 5758                          in cbook.safezip(y, yerr)]
   5759                 upper = [thisy + thiserr for (thisy, thiserr)
   5760                          in cbook.safezip(y, yerr)]

TypeError: unsupported operand type(s) for -: 'numpy.float64' and 'str'

In [ ]: