我已经建立了一个面板,p来自数据框,dfi就像这样
p=dfi.to_panel()
和 p 看起来像
In [1334]: p
Out[1334]:
<class 'pandas.core.panel.Panel'>
Dimensions: 3 (items) x 80 (major_axis) x 20 (minor_axis)
Items axis: bid to px
Major_axis axis: 2013-01-02 05:00:00 to 2013-04-29 04:00:00
Minor_axis axis: 02005NAB6 to 893647AP2
我建立了一个这样的模型(模型看起来很合理)
m=pd.ols(y=p['bid'],x={'px':p['px'],'qty':p['qty']},entity_effects=True, intercept=False)
给定新数据我如何做出预测?
我什至无法让这样的事情发挥作用。
m.predict(x=dfi) and m.predict(x=dfi.dropna()) both give NaN for all rows.
为了更有帮助,我从 pandas/stats/tests/test_ols.py
y = tm.makeTimeDataFrame()
x = Panel({'x1': tm.makeTimeDataFrame(),
'x2': tm.makeTimeDataFrame()})
result = ols(y=y, x=x)
pred=result.predict(x=x)
当我尝试这个预测时,我得到
ValueError Traceback (most recent call last)
...Omitted...
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/panel.pyc in reindex(self, major, minor, method, major_axis, minor_axis, copy, **kwargs)
815
816 def _reindex_multi(self, items, major, minor):
--> 817 a0, a1, a2 = len(items), len(major), len(minor)
818
819 values = self.values
ValueError: Must specify at least one axis