Q:

Pandas returning a copy when using the .at function in a Panel

All,
I'm currently trying to optimize some sub-routines of a small backtesting app I've built for myself. I have a 'current_data' pandas panel where all the data is held.
I'm trying to access it as follows:  
self.current_data.at[order['instrument'], self.current_day, 'low']

However, this is very slow. From the documentation, it seems that this should return a view - since I'm not setting any value. I'm using the latest pandas (0.11.0).
Would you be able to tell why this is going on? And maybe a faster way to do this?
By the way, I know that this is a copy because the profiler shows that frame.py:383(init) is being called every time, and if I reduce the size of the object this line speeds up tremendously.
Cheers!
Edit:
Here's how to re-create my issue. I see now that the issue is probably not in .at.
items = ['A', 'B', 'C', 'D']
cols = ['a', 'b', 'c', 'd']

indices = pd.date_range(datetime.datetime.now(), periods=1000, freq="D")
res = {}
for item in items:
    res[item] = pd.DataFrame(np.random.randn(1000, 4), columns=cols, index=indices)

first = pd.Panel(res)

print timeit.Timer("""
for i in range(100, 200):
    today = indices[i]
    first_change = first.ix[:, :i + 1, :]
    first_change.at["A", today, "a"]
    first_change.at["A", today, "b"]
    first_change.at["A", today, "c"]
""", setup="from __main__ import first, indices").timeit(number=50)/50.0

#--- Time: 0.0307311664639

indices = pd.date_range(datetime.datetime.now(), periods=10000, freq="D")
res = {}
for item in items:
    res[item] = pd.DataFrame(np.random.randn(10000, 4), columns=cols, index=indices)
second = pd.Panel(res)

print timeit.Timer("""
for i in range(8100, 8200):
    today = indices[i]
    second_change = second.ix[:, :i + 1, :]
    second_change.at["A", today, "a"]
    second_change.at["A", today, "b"]
    second_change.at["A", today, "c"]
""", setup="from __main__ import second, indices").timeit(number=50)/50.0

#--- Time: 0848793384464

Anyways, this is basically what's going on. It is probably in the .ix function, but it is simply returning a view so I don't see why it would take more time.
The issue is probably not in .at then, I think.

A:

You must be measuring something else, at is a constant time operation. Pls show some more detail in what you are doing (e.g. a sample panel and accessors)
In [24]: p = Panel(randn(1,1,1))

In [25]: %timeit p.at[0,0,0]
100000 loops, best of 3: 5.33 us per loop

In [26]: p = Panel(randn(10,10,10))

In [27]: %timeit p.at[0,0,0]
100000 loops, best of 3: 5.34 us per loop

In [28]: p = Panel(randn(100,100,100))

In [29]: %timeit p.at[0,0,0]
100000 loops, best of 3: 5.28 us per loop

In [30]: p = Panel(randn(1000,1000,1000))

In [31]: %timeit p.at[0,0,0]
100000 loops, best of 3: 5.36 us per loop

