Adding a DataFrame to an empty Panel - strange result

8 views
Skip to first unread message

Iain

unread,
Mar 6, 2012, 11:05:17 AM3/6/12
to pystatsmodels

I create an empty Panel p. I add an existing (non-empty) DataFrame df
to the Panel p as the first item using: p['foo'] = df.

I now have a Panel with one item ('foo'), but no rows or columns. It
seems that 'adding' the new item is doing an intersection of the rows
and columns of the empty Panel and the incoming DataFrame, and (not
surprisingly) finding none.

Is this the expected behavior? If so, is there an approved way to do
this? (I realize I can create the full dict of incoming data and then
create the Panel at the very end).

Thanks

Wes McKinney

unread,
Mar 6, 2012, 11:07:41 AM3/6/12
to pystat...@googlegroups.com

Neither Panel nor DataFrame can be resized by item insertion-- rather
the items are conformed to the existing axes which in this case are
empty. I would suggest setting the axes that you want on creation of
the Panel or waiting until the end to create it.

- Wes

Iain

unread,
Mar 6, 2012, 11:13:32 PM3/6/12
to pystatsmodels
Interesting. Thanks for the response!

On Mar 6, 11:07 am, Wes McKinney <wesmck...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages