I had a code that averaged exponentially from the pandas pd.ewma ()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-67-d81f5301d1c0> in <module>
55
56 # Smoothing the plot
---> 57 predictions_df_list['ewma'] = pd.ewma(predictions_df_list["prices"], span=20, freq="D") #pd.DataFrame.ewma
58 predictions_df_list['actual_value'] = test['prices']
59 predictions_df_list['actual_value_ewma'] = pd.ewma(predictions_df_list["actual_value"], span=20, freq="D")
AttributeError: module 'pandas' has no attribute 'ewma'
I found out that the package was in disuse. I tried to change to pd.Dataframe.ewm()
but
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-68-681b235459d9> in <module>
55
56 # Smoothing the plot
---> 57 predictions_df_list['ewma'] = pd.DataFrame.ewm(predictions_df_list["prices"], span=20) #pd.DataFrame.ewma
58 predictions_df_list['actual_value'] = test['prices']
59 predictions_df_list['actual_value_ewma'] = pd.DataFrame.ewm(predictions_df_list["actual_value"], span=20)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in __setitem__(self, key, value)
3117 else:
3118 # set column
-> 3119 self._set_item(key, value)
3120
3121 def _setitem_slice(self, key, value):
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in _set_item(self, key, value)
3192
3193 self._ensure_valid_index(value)
-> 3194 value = self._sanitize_column(key, value)
3195 NDFrame._set_item(self, key, value)
3196
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in _sanitize_column(self, key, value, broadcast)
3385 value = _sanitize_index(value, self.index, copy=False)
3386
-> 3387 elif isinstance(value, Index) or is_sequence(value):
3388 from pandas.core.series import _sanitize_index
3389
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\inference.py in is_sequence(obj)
470
471 try:
--> 472 iter(obj) # Can iterate over it.
473 len(obj) # Has a length associated with it.
474 return not isinstance(obj, string_and_binary_types)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\window.py in __iter__(self)
184 def __iter__(self):
185 url = 'https://github.com/pandas-dev/pandas/issues/11704'
--> 186 raise NotImplementedError('See issue #11704 {url}'.format(url=url))
187
188 def _get_index(self, index=None):
NotImplementedError: See issue #11704 https://github.com/pandas-dev/pandas/issues/11704
And it seems on the GitHub page that the current implementation does not use an explicit iterator, but rather an sliding window in python and marginal calculations.
So, how can I update this method?