Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:41:36+00:00 2026-06-15T09:41:36+00:00

I noticed some strange behavior when using IX on large pandas dataframes. When I

  • 0

I noticed some strange behavior when using IX on large pandas dataframes.

When I called .ix on the same dataframe 50 times in a row it ran 10 times faster than when I called .ix on 50 different dataframes.

Is there caching going on behind the scenes on .ix? I noticed that the bottom loop doubles my memory usage. Why would the memory be increasing?

Is there any way to modify this behavior?

Note that if you use straight up numpy it ran in 7.4 seconds in both cases with 0 memory increase, which is what led me to believe pandas was caching.

Obviously you never want to call .ix on each individual element…

import pandas as pd
import numpy as np
import datetime as dt
print 'pandas', pd.__version__

li_list = []
for i in range(50):
    li_list.append(pd.DataFrame(data=np.random.randn(50, 17000)))

print 'starting'

dt_start = dt.datetime.now()
a = 0
for i in range(50):
    b = li_list[0] #Only access first element
    for j in b.columns:
        a += b.ix[i, j]
print (dt.datetime.now()-dt_start).total_seconds()


dt_start = dt.datetime.now()
a = 0
for i in range(50):
    b = li_list[i] #Access all in list
    for j in b.columns:
        a += b.ix[i, j]
print (dt.datetime.now()-dt_start).total_seconds()

Output:

pandas 0.9.1
starting
3.651
22.009
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:41:37+00:00Added an answer on June 15, 2026 at 9:41 am

    Note: there is a hash table population step the first time you look up a location in an axis index. That’s probably what you’re seeing here and would be obscured by using timeit (because the hash table is computed once, stored, and reused). Also explains the increased memory usage.

    In a future version of pandas I plan to improve the performance of this type of code on simple data with simple sequential axis indexes. I’ll record your use case on the GitHub issue tracker.

    https://github.com/pydata/pandas/issues/2420

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I noticed some strange behavior when using a subclass of a NSManagedObject as
I recently noticed some strange behavior when using a returned empty shared_ptr. To illustrate
While writing script I noticed some very strange Perl behavior. The task is to
I have just noticed a strange behavior of ComboBox component. I am using it
I've noticed some strange behavior in iOS 5: NSSetUncaughtExceptionHandler() doesn't seem to do anything
I've noticed some strange behavior in SQL Server Express 2008, and I've been trying
Whilst building some unit tests for my Lucene queries I noticed some strange behavior
I am trying out the (latest) Android SDK, and noticed some strange behavior. I've
We've noticed some strange Cursor behavior, which we suspect is a result of one
Noticed Apache strange behavior. I'm using mod_rewrite to redirect every RewriteCond %{REQUEST_URI} !^.*css|gif|js|png$ RewriteRule

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.