Skip to content Skip to sidebar Skip to footer

How To Convert A List Of Data Frames To A Panel In Python-pandas?

Given a list of data frames with the following format: id age weight score date 01 11 50 90 2011-01-23 01 12 52 89 2012-03-23 ... Please note that the

Solution 1:

First step is to concat your frames together:

concated = pd.concat(list_of_frames)

Then, you can simply:

items = ['age', 'weight', 'score']
pd.Panel(dict(zip(items, [concated.pivot(index='date', columns='id', values=i) for i in items])))

This is so nicely specified in this documentation.

Post a Comment for "How To Convert A List Of Data Frames To A Panel In Python-pandas?"