In [1]:
import numpy as np
decays_arr = np.loadtxt('data/decays.csv', delimiter=",", skiprows=1)
decays_arr


Out[1]:
array([[  0.00000000e+00,   1.00000000e+01],
       [  1.00000000e+00,   1.35335283e+00],
       [  2.00000000e+00,   1.83156389e-01],
       [  3.00000000e+00,   2.47875220e-02],
       [  4.00000000e+00,   3.35462600e-03],
       [  5.00000000e+00,   4.53999000e-04],
       [  6.00000000e+00,   6.14420000e-05],
       [  7.00000000e+00,   8.31500000e-06],
       [  8.00000000e+00,   1.12600000e-06],
       [  9.00000000e+00,   1.52000000e-07]])

In [2]:
import pandas as pd
decays_df = pd.read_csv('data/decays.csv') 
decays_df


Out[2]:
Time (s) Decays (#)
0 0 1.000000e+01
1 1 1.353353e+00
2 2 1.831564e-01
3 3 2.478752e-02
4 4 3.354626e-03
5 5 4.539990e-04
6 6 6.144200e-05
7 7 8.315000e-06
8 8 1.126000e-06
9 9 1.520000e-07

In [3]:
# can convert to HDF5 format
#decays_df.to_hdf('decays.h5', 'experimental')

In [4]:
import blaze as bz
csv_data = bz.CSV('data/decays.csv')
decays_tb = bz.Table(csv_data)

In [5]:
decay_df = pd.read_csv("data/many_decays.csv")
decay_df.count()


Out[5]:
Time      50
Decays    46
dtype: int64

In [6]:
decay_df.dropna()


Out[6]:
Time Decays
0 2014-11-08T05:19:31.561782 1.000000e+01
1 2014-11-08T05:19:32.561782 1.353353e+00
2 2014-11-08T05:19:33.561782 1.831564e-01
3 2014-11-08T05:19:34.561782 2.478752e-02
4 2014-11-08T05:19:35.561782 3.354626e-03
5 2014-11-08T05:19:36.561782 4.539993e-04
6 2014-11-08T05:19:37.561782 6.144212e-05
7 2014-11-08T05:19:38.561782 8.315287e-06
8 2014-11-08T05:19:39.561782 1.125352e-06
9 2014-11-08T05:19:40.561782 1.522998e-07
10 2014-11-08T05:19:41.561782 2.061154e-08
11 2014-11-08T05:19:42.561782 2.789468e-09
12 2014-11-08T05:19:43.561782 3.775135e-10
13 2014-11-08T05:19:44.561782 5.109089e-11
14 2014-11-08T05:19:45.561782 6.914400e-12
15 2014-11-08T05:19:46.561782 9.357623e-13
16 2014-11-08T05:19:47.561782 2.000000e+00
17 2014-11-08T05:19:48.561782 2.000000e+00
18 2014-11-08T05:19:49.561782 2.000000e+00
19 2014-11-08T05:19:50.561782 2.000000e+00
20 2014-11-08T05:19:51.561782 2.000000e+00
21 2014-11-08T05:19:52.561782 2.000000e+00
22 2014-11-08T05:19:53.561782 2.000000e+00
23 2014-11-08T05:19:54.561782 2.000000e+00
24 2014-11-08T05:19:55.561782 2.000000e+00
25 2014-11-08T05:19:56.561782 1.928750e-21
26 2014-11-08T05:19:57.561782 2.610279e-22
27 2014-11-08T05:19:58.561782 3.532629e-23
28 2014-11-08T05:19:59.561782 4.780893e-24
29 2014-11-08T05:20:00.561782 6.470235e-25
30 2014-11-08T05:20:01.561782 8.756511e-26
31 2014-11-08T05:20:02.561782 1.185065e-26
32 2014-11-08T05:20:03.561782 1.603811e-27
33 2014-11-08T05:20:04.561782 2.170522e-28
34 2014-11-08T05:20:05.561782 2.937482e-29
35 2014-11-08T05:20:06.561782 3.975450e-30
36 2014-11-08T05:20:07.561782 5.380186e-31
37 2014-11-08T05:20:08.561782 7.281290e-32
38 2014-11-08T05:20:09.561782 9.854155e-33
39 2014-11-08T05:20:10.561782 1.333615e-33
40 2014-11-08T05:20:11.561782 1.804851e-34
45 2014-11-08T05:20:16.561782 8.194013e-39
46 2014-11-08T05:20:17.561782 1.108939e-39
47 2014-11-08T05:20:18.561782 1.500786e-40
48 2014-11-08T05:20:19.561782 2.031093e-41
49 2014-11-08T05:20:20.561782 2.748785e-42

In [7]:
import numpy as np

# as in the previous example, load decays.csv into a NumPy array
decaydata = np.loadtxt('data/decays.csv', delimiter=",", skiprows=1)

# provide handles for the x and y columns
time = decaydata[:,0]
decays = decaydata[:,1]

# import the matplotlib plotting functionality
import matplotlib
%matplotlib inline
import pylab as plt

plt.plot(time, decays)

plt.xlabel('Time (s)')
plt.ylabel('Decays')
plt.title('Decays')
plt.grid(True)
#plt.savefig("decays_matplotlib.png")



In [8]:
# Import various necessary Python and matplotlib packages
import numpy as np
import matplotlib.cm as cm
from matplotlib.pyplot import figure, show, rc
from matplotlib.patches import Ellipse

# Create a square figure on which to place the plot
fig = figure(figsize=(8,8))

# Create square axes to hold the circular polar plot
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)

# Generate 20 colored, angular wedges for the polar plot
N = 20
theta = np.arange(0.0, 2*np.pi, 2*np.pi/N)
radii = 10*np.random.rand(N)
width = np.pi/4*np.random.rand(N)
bars = ax.bar(theta, radii, width=width, bottom=0.0)
for r,bar in zip(radii, bars):
    bar.set_facecolor(cm.jet(r/10.))
    bar.set_alpha(0.5)

# Using dictionaries, create a color scheme for the text boxes
bbox_args = dict(boxstyle="round, pad=0.9", fc="green", alpha=0.5)
bbox_white = dict(boxstyle="round, pad=0.9", fc="1", alpha=0.9)
patch_white = dict(boxstyle="round, pad=1", fc="1", ec="1")

# Create various boxes with text annotations in them at specific
# x and y coordinates
ax.annotate(" ",
    xy=(.5,.93),
    xycoords='figure fraction',
    ha="center", va="center",
    bbox=patch_white)

ax.annotate('Matplotlib and the Python Ecosystem for Scientific Computing',
    xy=(.5,.95),
    xycoords='figure fraction',
    xytext=(0, 0), textcoords='offset points',
    size=15,
    ha="center", va="center",
    bbox=bbox_args)

ax.annotate('Author and Lead Developer \n of Matplotlib ',
    xy=(.5,.82),
    xycoords='figure fraction',
    xytext=(0, 0), textcoords='offset points',
    ha="center", va="center",
    bbox=bbox_args)

ax.annotate('John D. Hunter',
    xy=(.5,.89),
    xycoords='figure fraction',
    xytext=(0, 0), textcoords='offset points',
    size=15,
    ha="center", va="center",
    bbox=bbox_white)

ax.annotate('Friday November 5th  \n 2:00 pm \n1106ME ',
    xy=(.5,.25),
    xycoords='figure fraction',
    xytext=(0, 0), textcoords='offset points',
    size=15,
    ha="center", va="center",
    bbox=bbox_args)

ax.annotate('Sponsored by: \n The Hacker Within, \n'
    'The University Lectures Committee, \n The Department of '
    'Medical Physics\n and \n The American Nuclear Society',
    xy=(.78,.1),
    xycoords='figure fraction',
    xytext=(0, 0), textcoords='offset points',
    size=9,
    ha="center", va="center",
    bbox=bbox_args)

#fig.savefig("plot.pdf")


Out[8]:
<matplotlib.text.Annotation at 0x7f36d147cf28>

In [9]:
import numpy as np
# import the Bokeh plotting tools
from bokeh import plotting as bp

# as in the matplotlib example, load decays.csv into a NumPy array
decaydata = np.loadtxt('data/decays.csv',delimiter=",",skiprows=1)

# provide handles for the x and y columns
time = decaydata[:,0]
decays = decaydata[:,1]

# define some output file metadata
bp.output_file("decays.html", title="Experiment 1 Radioactivity")

# create a figure with fun Internet-friendly features (optional)
bp.figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave")

# on that figure, create a line plot
bp.line(time, decays, x_axis_label="Time (s)", y_axis_label="Decays (#)",
     color='#1F78B4', legend='Decays per second')

# additional customization to the figure can be specified separately
bp.curplot().title = "Decays"
bp.grid().grid_line_alpha=0.3

# open a browser
bp.show()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-d30fac41d608> in <module>()
     17 
     18 # on that figure, create a line plot
---> 19 bp.line(time, decays, x_axis_label="Time (s)", y_axis_label="Decays (#)",
     20      color='#1F78B4', legend='Decays per second')
     21 

AttributeError: 'module' object has no attribute 'line'