1
通过继承DateOffset
实现在大熊猫定制频率后的自定义偏移别名,是有可能为“注册”的偏移别名针对该频率使得别名可以在内藏大熊猫功能如date_range
使用和resample
?使用在大熊猫
例如,假设我实现一个自定义每月两次的频率:
from pandas.tseries.offsets import DateOffset, CacheableOffset
class TwiceMonthly(DateOffset, CacheableOffset):
def apply(self, other):
# Some date logic here
@property
def rule_code(self):
return 'TM'
现在,而不是使用TwiceMonthly()
无处不在,我想用偏移别名TM。
# Suppose s is a time series
s.resample('TM', how='sum')
我创建了一个问题,以防有人出现并想要这样做:http://github.com/pydata/pandas/issues/2089 –