pandas.tseries.offsets

Class nameDescription
DateOffsetGeneric offset class, defaults to 1 calendar day
BDaybusiness day (weekday)
CDay这个可以设置特定的假期
Weekone week, optionally anchored on a day of the week
WeekOfMonththe x-th day of the y-th week of each month
LastWeekOfMonththe x-th day of the last week of each month
MonthEndcalendar month end
MonthBegincalendar month begin
BMonthEndbusiness month end
BMonthBeginbusiness month begin
CBMonthEndcustom business month end
CBMonthBegincustom business month begin
SemiMonthEnd15th (or other day_of_month) and calendar month end
SemiMonthBegin15th (or other day_of_month) and calendar month begin
QuarterEndcalendar quarter end
QuarterBegincalendar quarter begin
BQuarterEndbusiness quarter end
BQuarterBeginbusiness quarter begin
FY5253Quarterretail (aka 52-53 week) quarter
YearEndcalendar year end
YearBegincalendar year begin
BYearEndbusiness year end
BYearBeginbusiness year begin
FY5253retail (aka 52-53 week) year
BusinessHour可以自己设置工作时间
CustomBusinessHourcustom business hour
Hourone hour
Minuteone minute
Secondone second
Millione millisecond
Microone microsecond
Nanoone nanosecond
from pandas.tseries.offsets import *
d = datetime(2008, 8, 18, 9, 0)
In [106]: d + DateOffset(months=4, days=5)
Out[106]: Timestamp('2008-12-23 09:00:00')
In [107]: d - 5 * BDay()
Out[107]: Timestamp('2008-08-11 09:00:00')

In [108]: d + BMonthEnd()
Out[108]: Timestamp('2008-08-29 09:00:00')

In [109]: d
Out[109]: datetime.datetime(2008, 8, 18, 9, 0)

In [110]: offset = BMonthEnd()

In [111]: offset.rollforward(d)
Out[111]: Timestamp('2008-08-29 09:00:00')

In [112]: offset.rollback(d)
Out[112]: Timestamp('2008-07-31 09:00:00')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值