Skip to content

PERF: optimize __getitem__ in DataFrame for columns lookup #4639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Aug 22, 2013

In [1]: df2 = DataFrame(randn(3000,1),columns=['A'])
In [2]: df3 = DataFrame(randn(3000,1))
In [3]: def h():
   ...:         for i in xrange(10000):
   ...:                 df2['A']
   ...:         
In [4]: def j():
   ...:         for i in xrange(10000):
   ...:                 df3[0]
   ...:         

0.12

In [5]: %timeit h()
%time10 loops, best of 3: 39.8 ms per loop

In [6]: %timeit j()
10 loops, best of 3: 31.8 ms per loop

with PR

In [8]: %timeit h()
10 loops, best of 3: 25.5 ms per loop

In [9]: %timeit j()
10 loops, best of 3: 27.4 ms per loop

and the vbench

-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
frame_getitem_single_column                  |  25.5514 |  43.3776 |   0.5890 |
frame_getitem_single_column2                 |  27.3627 |  32.4320 |   0.8437 |

jreback added a commit that referenced this pull request Aug 23, 2013
PERF: optimize __getitem__ in DataFrame for columns lookup
@jreback jreback merged commit 0958d5f into pandas-dev:master Aug 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant