I would expect to be able to perform an ewma
over each minor axis within each major axis:
In [52]:
wp = pd.Panel(np.random.randn(2, 4, 5), items=['Item1', 'Item2'],
minor_axis=pd.date_range('1/1/2000', periods=5),
major_axis=['A', 'B', 'C', 'D'])
In [57]:
wp
Out[57]:
<class 'pandas.core.panel.Panel'>
Dimensions: 2 (items) x 4 (major_axis) x 5 (minor_axis)
Items axis: Item1 to Item2
Major_axis axis: A to D
Minor_axis axis: 2000-01-01 00:00:00 to 2000-01-05 00:00:00
In [56]:
pd.ewma(wp, com=2)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-56-bb436def494f> in <module>()
----> 1 pd.ewma(wp, com=2)
/usr/local/lib/python2.7/dist-packages/pandas-0.13.0_285_gfcfaa7d-py2.7-linux-x86_64.egg/pandas/stats/moments.pyc in ewma(arg, com, span, halflife, min_periods, freq, time_rule, adjust)
373 return result
374
--> 375 return_hook, values = _process_data_structure(arg)
376 output = np.apply_along_axis(_ewma, 0, values)
377 return return_hook(output)
/usr/local/lib/python2.7/dist-packages/pandas-0.13.0_285_gfcfaa7d-py2.7-linux-x86_64.egg/pandas/stats/moments.pyc in _process_data_structure(arg, kill_inf)
329 values = arg
330
--> 331 if not issubclass(values.dtype.type, float):
332 values = values.astype(float)
333
/usr/local/lib/python2.7/dist-packages/pandas-0.13.0_285_gfcfaa7d-py2.7-linux-x86_64.egg/pandas/core/generic.pyc in __getattr__(self, name)
1802 return self[name]
1803 raise AttributeError("'%s' object has no attribute '%s'" %
-> 1804 (type(self).__name__, name))
1805
1806 def __setattr__(self, name, value):
AttributeError: 'Panel' object has no attribute 'dtype'
Comment From: jreback
not implemented
Comment From: cancan101
Agreed. Does this seem like a reasonable feature? That being said, how would one go about performing such an ewma
on a DataFrame or Series?
Comment From: jreback
you can use Panel.apply
(newly enhanced in 0.13.1) to apply to the Frame (or Series), see here: http://pandas.pydata.org/pandas-docs/dev/whatsnew.html#enhancements.
I personally just use a dict iteration and build new objects with a function (I will switch to apply at some point though, cleaner syntax).
Then usually concat the results, that way you can control whether you build same / higher / or lower dimensional objects.
Comment From: jreback
closing as Panels are deprecated