A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/7763 below:

Assigning Panel item using .ix/.loc no longer works · Issue #7763 · pandas-dev/pandas · GitHub

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4