[SciPy-user] Record Array: How to add a column?

John Hunter jdh2358@gmail....
Tue Oct 14 10:53:08 CDT 2008


On Tue, Oct 14, 2008 at 10:02 AM, Huang-Wen Chen
<hwchen.mailman@gmail.com> wrote:

> The example is amazing. It's so simple to do the elegant job, but I think it
> requires some modification because the the size of the two dataset is
> different:
>
> In [68]: r1.shape
> Out[68]: (6080,)
>
> In [69]: r2.shape
> Out[69]: (1046,)

No, that is one of the main points of the example in the call to
rec_join -- it does an inner join (intersection)  aligned by date.
Since it is an inner join, dates in one that are not in the other are
dropped.  It can also do an outer join (union) using the "jointype"
keyword arg to rec_join.

But thanks for the kind words on the example -- I agree.  Record
arrays are really powerful data structures and with some of the
functions in mlab, which hopefully will end up in some form in numpy
eventually, you have much of the flexibility of sql tables.  See for
example 'group by' using
record arrays in rec_groupby_demo.py at

  http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/examples/misc/

JDH


More information about the SciPy-user mailing list