Skip to content

Improve Panel slicing speed #979

Closed
Closed
@wesm

Description

@wesm

from mailing list:


To follow up:

I used timeit.Timer() to time this two different ways:
a) return a slice of a Panel using panel.ix[foo, bar, qux] (where foo,
bar, and qux are arrays)
b) i) iterate through the items of the panel that are in foo
   ii) do a slice on each DataFrame with data.ix[bar, qux]
   iii) save the slice
   iv) reassemble the slices into a new, smaller Panel
   v) return the new Panel

For the data I was using (10 items x 768432 major x 9 minor), the
results I got were:
   t = timeit.Timer(a, setup=setup)
   print min(t.repeat(repeat=3, number=10))
   2.52914

   t = timeit.Timer(b, setup=setup)
   print min(t.repeat(repeat=3, number=10))
   0.54757

This seems odd to me. Approach b is not only faster than a, but almost
5-fold faster. It appears that Panel.ix[foo, bar, qux] is doing
something even slower than the dumb approach embodied in B - either
that or I'm doing something horribly wrong! :-)


Iain

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions