Using Pickle with dictionaries


In [3]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [4]:
import pickle

In [6]:
mydict = dict()
mydict['obs1']  = np.random.rand(100)
mydict['obs2']  = np.random.normal(0, 1, 100)

Saving dictionary


In [8]:
pickle.dump( mydict, open( "mydic.p", "wb" ) )

Reading a dictionary


In [9]:
mynewdict = pickle.load(open('mydic.p', 'rb'))

In [12]:
plt.scatter(mynewdict['obs1'], mynewdict['obs2'], color='k')


Out[12]:
<matplotlib.collections.PathCollection at 0x7f4fb6b6a590>