Former-commit-id:a02aeb236c
[formerly9f19e3f712
] [formerlya02aeb236c
[formerly9f19e3f712
] [formerly06a8b51d6d
[formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]] Former-commit-id:06a8b51d6d
Former-commit-id:8e80217e59
[formerly3360eb6c5f
] Former-commit-id:377dcd10b9
27 lines
663 B
Python
Executable file
27 lines
663 B
Python
Executable file
import numpy as np
|
|
import matplotlib.mlab as mlab
|
|
|
|
|
|
r = mlab.csv2rec('../data/aapl.csv')
|
|
r.sort()
|
|
r1 = r[-10:]
|
|
|
|
# Create a new array
|
|
r2 = np.empty(12, dtype=[('date', '|O4'), ('high', np.float),
|
|
('marker', np.float)])
|
|
r2 = r2.view(np.recarray)
|
|
r2.date = r.date[-17:-5]
|
|
r2.high = r.high[-17:-5]
|
|
r2.marker = np.arange(12)
|
|
|
|
print "r1:"
|
|
print mlab.rec2txt(r1)
|
|
print "r2:"
|
|
print mlab.rec2txt(r2)
|
|
|
|
defaults = {'marker':-1, 'close':np.NaN, 'low':-4444.}
|
|
|
|
for s in ('inner', 'outer', 'leftouter'):
|
|
rec = mlab.rec_join(['date', 'high'], r1, r2,
|
|
jointype=s, defaults=defaults)
|
|
print "\n%sjoin :\n%s" % (s, mlab.rec2txt(rec))
|