def ema(f, c, p = 20):
r"""Calculate the mean on a rolling basis.
Parameters
----------
f : pandas.DataFrame
Dataframe containing the column ``c``.
c : str
Name of the column in the dataframe ``f``.
p : int
The period over which to calculate the rolling mean.
Returns
-------
new_column : pandas.Series (float)
The array containing the new feature.
References
----------
*An exponential moving average (EMA) is a type of moving average
that is similar to a simple moving average, except that more weight
is given to the latest data* [IP_EMA]_.
.. [IP_EMA] http://www.investopedia.com/terms/e/ema.asp
"""
new_column = pd.ewma(f[c], span=p)
return new_column
#
# Function maratio
#
评论列表
文章目录