Closed
Description
I am updating a codebase from an OLD version of pandas (0.7.3) to current version (0.14.1).
pandas: 0.14.1
numpy: 1.8.0
The following code has stopped working correctly (using .ix[] or .loc[]):
import numpy as np
import pandas as ps
np.random.seed(0)
index=range(3)
columns = list('abc')
panel = ps.Panel({'A' : ps.DataFrame(np.random.randn(3, 3), index=index, columns=columns),
'B' : ps.DataFrame(np.random.randn(3, 3), index=index, columns=columns),
'C' : ps.DataFrame(np.random.randn(3, 3), index=index, columns=columns)
})
replace = ps.DataFrame(np.eye(3,3), index=range(3), columns=columns)
print panel['A']
for idx in list('ABC'):
panel.loc[idx,:,:] = replace
print panel['A']
Output:
a b c
0 1.764052 0.400157 0.978738
1 2.240893 1.867558 -0.977278
2 0.950088 -0.151357 -0.103219
a b c
0 NaN NaN NaN
1 NaN NaN NaN
2 NaN NaN NaN
However, if I simply do this:
for idx in list('ABC'):
panel[idx] = replace
print panel['A']
It behaves as expected:
a b c
0 1 0 0
1 0 1 0
2 0 0 1
Also, if I assign more than just the item, it works fine:
panel.loc['A', 0, 'a'] = 1.0
print panel['A']
a b c
0 1.000000 0.400157 0.978738
1 2.240893 1.867558 -0.977278
2 0.950088 -0.151357 -0.103219
Thanks.