我有一个投资定价数据的 pandas 面板,我想向其中添加两个新的短轴列(投资组合持有和基准持有)。
初始面板是:
<class 'pandas.core.panel.Panel'>
Dimensions: 4 (items) x 463 (major) x 8 (minor)
Items: ListedEquity:BHP Billiton:BHP.AX to SavingsAccount:ING Australia Savings Maximiser
Major axis: 2010-01-04 00:00:00 to 2011-10-31 00:00:00
Minor axis: content_type to xrate
从概念上讲,它看起来像:
Investment 1 Investment 2
c1 c2 c3... c1 c2 c3...
Date 1
Date 2
...
是否可以创建一个仅包含这些列的匹配面板,然后以某种方式合并这两个面板?
关于实现这一目标的可能替代方法的想法?
关于面板数据结构的文档非常简单。
编辑:
我创建了第二个面板并尝试了 p1.join(p2) 但这会生成列重叠错误。
这是我想附加的第二个面板:
<class 'pandas.core.panel.Panel'>
Dimensions: 4 (items) x 463 (major) x 2 (minor)
Items: ListedEquity:BHP Billiton:BHP.AX to SavingsAccount:Comsec Cash Management Account
Major axis: 2010-01-04 00:00:00 to 2011-10-31 00:00:00
Minor axis: benchmark to portfolio
I have a pandas panel of investment pricing data to which I want to add two new minor axis columns (portfolio holding and benchmark holding).
The initial panel is:
<class 'pandas.core.panel.Panel'>
Dimensions: 4 (items) x 463 (major) x 8 (minor)
Items: ListedEquity:BHP Billiton:BHP.AX to SavingsAccount:ING Australia Savings Maximiser
Major axis: 2010-01-04 00:00:00 to 2011-10-31 00:00:00
Minor axis: content_type to xrate
which conceptually looks like:
Investment 1 Investment 2
c1 c2 c3... c1 c2 c3...
Date 1
Date 2
...
Is it possible create a matching panel that only has these columns and then somehow merge the two?
Thoughts on possible alternative ways of achieving this?
The documentation on the Panel data structure is pretty bare.
EDIT:
I created the 2nd panel and tried p1.join(p2) but this generates a columns overlap error.
Here's the 2nd panel I would like to append:
<class 'pandas.core.panel.Panel'>
Dimensions: 4 (items) x 463 (major) x 2 (minor)
Items: ListedEquity:BHP Billiton:BHP.AX to SavingsAccount:Comsec Cash Management Account
Major axis: 2010-01-04 00:00:00 to 2011-10-31 00:00:00
Minor axis: benchmark to portfolio
发布评论
评论(1)
抱歉,我前段时间错过了这个问题。您可以看一下 pandas 0.7.0 中的新 concat 函数,看看它是否满足您的需求:
http://pandas.pydata.org/pandas-docs/stable/merging.html#concatenating-objects
我最近花了很多时间连接和串联方法。
Sorry I missed this question some time ago. Could you have a look at the new concat function in pandas 0.7.0 and see if it meets your needs:
http://pandas.pydata.org/pandas-docs/stable/merging.html#concatenating-objects
I recently spent a great deal of time on the join and concatenation methods.