Closed
Description
related to #3777
It seems that assigning a DataFrame to a Panel slice doesn't work correctly.
Unless I'm mistaken the below test code should work:
a = np.zeros((2,4,5))
panel = pd.Panel(a, items=['a1','a2'])
df = pd.DataFrame(a[0,:,:])
np.testing.assert_equal(panel.loc['a1'].values, df.values)
np.testing.assert_equal(panel.loc['a2'].values, df.values)
# Assignment by Value Passes for 'a2'
panel.loc['a2'] = df.values
np.testing.assert_equal(panel.loc['a1'].values, df.values)
np.testing.assert_equal(panel.loc['a2'].values, df.values)
# Assignment by DataFrame Fails for 'a2'
panel.loc['a2'] = df
np.testing.assert_equal(panel.loc['a1'].values, df.values)
np.testing.assert_equal(panel.loc['a2'].values, df.values)
Traceback (most recent call last):
File "C:\Users\dhirschfeld\.spyder2\temp.py", line 41, in <module>
np.testing.assert_equal(panel.loc['a2'].values, df.values)
File "C:\dev\bin\Python27\lib\site-packages\numpy\testing\utils.py", line 257, in assert_equal
return assert_array_equal(actual, desired, err_msg, verbose)
File "C:\dev\bin\Python27\lib\site-packages\numpy\testing\utils.py", line 588, in chk_same_position
raise AssertionError(msg)
AssertionError:
Arrays are not equal
x and y nan location mismatch:
x: array([[ 0., 0., 0., 0., nan],
[ 0., 0., 0., 0., nan],
[ 0., 0., 0., 0., nan],
[ 0., 0., 0., 0., nan]])
y: array([[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.]])