Pandas 股票投资组合面板

发布于 2024-12-17 18:43:02 字数 960 浏览 0 评论 0 原文

我有一个投资定价数据的 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帝王念 2024-12-24 18:43:02

抱歉,我前段时间错过了这个问题。您可以看一下 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文