本文整理汇总了Python中pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs.average_by_month方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeriesCalcs.average_by_month方法的具体用法?Python TimeSeriesCalcs.average_by_month怎么用?Python TimeSeriesCalcs.average_by_month使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs
的用法示例。
在下文中一共展示了TimeSeriesCalcs.average_by_month方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: monthly_seasonality
# 需要导入模块: from pythalesians.timeseries.calcs.timeseriescalcs import TimeSeriesCalcs [as 别名]
# 或者: from pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs import average_by_month [as 别名]
def monthly_seasonality(self, data_frame,
cum = True,
add_average = False, price_index = False):
tsc = TimeSeriesCalcs()
if price_index:
data_frame = data_frame.resample('BM') # resample into month end
data_frame = tsc.calculate_returns(data_frame)
data_frame.index = pandas.to_datetime(data_frame.index)
monthly_seasonality = tsc.average_by_month(data_frame)
if add_average:
monthly_seasonality['Avg'] = monthly_seasonality.mean(axis=1)
if cum is True:
monthly_seasonality.loc[0] = numpy.zeros(len(monthly_seasonality.columns))
monthly_seasonality = monthly_seasonality.sort()
monthly_seasonality = tsc.create_mult_index(monthly_seasonality)
return monthly_seasonality