[Numpy-discussion] How to implement a 'pivot table?'

Vincent vincent.nijs at gmail.com
Wed Aug 1 11:30:21 EDT 2007


I do a lot of this kind of things in SAS. In don't like SAS that much
so it would be great to have functionality like this for numpy
recarray's.

To transplant the approach that SAS takes to a numpy setting you'd
have something like the following 4 steps:
1. Sort the data by date and region
2. Determine the indices for the blocks (e.g., East, 1/1)
3. calculate the summary stats per block

SAS is very efficient at these types of operations i believe. Since it
assumes that the data is sorted, and throws and error if the data is
not sorted appropriately, i assume the indexing can be more efficient.
However, given the earlier comments i am wonder if this approach would
enhance performance.

I would be very interested to see what you come up with so please post
some of the code and/or timing tests to the list if possible.

Best,

Vincent




More information about the NumPy-Discussion mailing list