@@ -1397,7 +1397,22 @@ cdef class YearOffset(SingleConstructorOffset):
1397
1397
1398
1398
cdef class BYearEnd(YearOffset):
1399
1399
"""
1400
- DateOffset increments between business EOM dates.
1400
+ DateOffset increments between the last business day of the year.
1401
+
1402
+ Examples
1403
+ --------
1404
+ >>> from pandas.tseries.offset import BYearEnd
1405
+ >>> ts = pd.Timestamp('2020-05-24 05:01:15')
1406
+ >>> ts - BYearEnd()
1407
+ Timestamp('2019-12-31 05:01:15')
1408
+ >>> ts + BYearEnd()
1409
+ Timestamp('2020-12-31 05:01:15')
1410
+ >>> ts + BYearEnd(3)
1411
+ Timestamp('2022-12-30 05:01:15')
1412
+ >>> ts + BYearEnd(-3)
1413
+ Timestamp('2017-12-29 05:01:15')
1414
+ >>> ts + BYearEnd(month=11)
1415
+ Timestamp('2020-11-30 05:01:15')
1401
1416
"""
1402
1417
1403
1418
_outputName = " BusinessYearEnd"
@@ -1408,7 +1423,20 @@ cdef class BYearEnd(YearOffset):
1408
1423
1409
1424
cdef class BYearBegin(YearOffset):
1410
1425
"""
1411
- DateOffset increments between business year begin dates.
1426
+ DateOffset increments between the first business day of the year.
1427
+
1428
+ Examples
1429
+ --------
1430
+ >>> from pandas.tseries.offset import BYearBegin
1431
+ >>> ts = pd.Timestamp('2020-05-24 05:01:15')
1432
+ >>> ts + BYearBegin()
1433
+ Timestamp('2021-01-01 05:01:15')
1434
+ >>> ts - BYearBegin()
1435
+ Timestamp('2020-01-01 05:01:15')
1436
+ >>> ts + BYearBegin(-1)
1437
+ Timestamp('2020-01-01 05:01:15')
1438
+ >>> ts + BYearBegin(2)
1439
+ Timestamp('2022-01-03 05:01:15')
1412
1440
"""
1413
1441
1414
1442
_outputName = " BusinessYearBegin"
@@ -1516,11 +1544,24 @@ cdef class QuarterOffset(SingleConstructorOffset):
1516
1544
1517
1545
cdef class BQuarterEnd(QuarterOffset):
1518
1546
"""
1519
- DateOffset increments between business Quarter dates .
1547
+ DateOffset increments between the last business day of each Quarter .
1520
1548
1521
1549
startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ...
1522
1550
startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ...
1523
1551
startingMonth = 3 corresponds to dates like 3/30/2007, 6/29/2007, ...
1552
+
1553
+ Examples
1554
+ --------
1555
+ >>> from pandas.tseries.offset import BQuarterEnd
1556
+ >>> ts = pd.Timestamp('2020-05-24 05:01:15')
1557
+ >>> ts + BQuarterEnd()
1558
+ Timestamp('2020-06-30 05:01:15')
1559
+ >>> ts + BQuarterEnd(2)
1560
+ Timestamp('2020-09-30 05:01:15')
1561
+ >>> ts + BQuarterEnd(1, startingMonth=2)
1562
+ Timestamp('2020-05-29 05:01:15')
1563
+ >>> ts + BQuarterEnd(startingMonth=2)
1564
+ Timestamp('2020-05-29 05:01:15')
1524
1565
"""
1525
1566
_outputName = " BusinessQuarterEnd"
1526
1567
_default_startingMonth = 3
@@ -1529,11 +1570,28 @@ cdef class BQuarterEnd(QuarterOffset):
1529
1570
_day_opt = " business_end"
1530
1571
1531
1572
1532
- # TODO: This is basically the same as BQuarterEnd
1533
1573
cdef class BQuarterBegin(QuarterOffset):
1574
+ """
1575
+ DateOffset increments between the first business day of each Quarter.
1576
+
1577
+ startingMonth = 1 corresponds to dates like 1/01/2007, 4/01/2007, ...
1578
+ startingMonth = 2 corresponds to dates like 2/01/2007, 5/01/2007, ...
1579
+ startingMonth = 3 corresponds to dates like 3/01/2007, 6/01/2007, ...
1580
+
1581
+ Examples
1582
+ --------
1583
+ >>> from pandas.tseries.offset import BQuarterBegin
1584
+ >>> ts = pd.Timestamp('2020-05-24 05:01:15')
1585
+ >>> ts + BQuarterBegin()
1586
+ Timestamp('2020-06-01 05:01:15')
1587
+ >>> ts + BQuarterBegin(2)
1588
+ Timestamp('2020-09-01 05:01:15')
1589
+ >>> ts + BQuarterBegin(startingMonth=2)
1590
+ Timestamp('2020-08-03 05:01:15')
1591
+ >>> ts + BQuarterBegin(-1)
1592
+ Timestamp('2020-03-02 05:01:15')
1593
+ """
1534
1594
_outputName = " BusinessQuarterBegin"
1535
- # I suspect this is wrong for *all* of them.
1536
- # TODO: What does the above comment refer to?
1537
1595
_default_startingMonth = 3
1538
1596
_from_name_startingMonth = 1
1539
1597
_prefix = " BQS"
@@ -1542,7 +1600,7 @@ cdef class BQuarterBegin(QuarterOffset):
1542
1600
1543
1601
cdef class QuarterEnd(QuarterOffset):
1544
1602
"""
1545
- DateOffset increments between business Quarter dates.
1603
+ DateOffset increments between Quarter end dates.
1546
1604
1547
1605
startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ...
1548
1606
startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ...
@@ -1555,6 +1613,13 @@ cdef class QuarterEnd(QuarterOffset):
1555
1613
1556
1614
1557
1615
cdef class QuarterBegin(QuarterOffset):
1616
+ """
1617
+ DateOffset increments between Quarter start dates.
1618
+
1619
+ startingMonth = 1 corresponds to dates like 1/01/2007, 4/01/2007, ...
1620
+ startingMonth = 2 corresponds to dates like 2/01/2007, 5/01/2007, ...
1621
+ startingMonth = 3 corresponds to dates like 3/01/2007, 6/01/2007, ...
1622
+ """
1558
1623
_outputName = " QuarterBegin"
1559
1624
_default_startingMonth = 3
1560
1625
_from_name_startingMonth = 1
@@ -1601,15 +1666,37 @@ cdef class MonthBegin(MonthOffset):
1601
1666
1602
1667
cdef class BusinessMonthEnd(MonthOffset):
1603
1668
"""
1604
- DateOffset increments between business EOM dates.
1669
+ DateOffset increments between the last business day of the month
1670
+
1671
+ Examples
1672
+ --------
1673
+ >>> from pandas.tseries.offset import BMonthEnd
1674
+ >>> ts = pd.Timestamp('2020-05-24 05:01:15')
1675
+ >>> ts + BMonthEnd()
1676
+ Timestamp('2020-05-29 05:01:15')
1677
+ >>> ts + BMonthEnd(2)
1678
+ Timestamp('2020-06-30 05:01:15')
1679
+ >>> ts + BMonthEnd(-2)
1680
+ Timestamp('2020-03-31 05:01:15')
1605
1681
"""
1606
1682
_prefix = " BM"
1607
1683
_day_opt = " business_end"
1608
1684
1609
1685
1610
1686
cdef class BusinessMonthBegin(MonthOffset):
1611
1687
"""
1612
- DateOffset of one business month at beginning.
1688
+ DateOffset of one month at the first business day.
1689
+
1690
+ Examples
1691
+ --------
1692
+ >>> from pandas.tseries.offset import BMonthBegin
1693
+ >>> ts=pd.Timestamp('2020-05-24 05:01:15')
1694
+ >>> ts + BMonthBegin()
1695
+ Timestamp('2020-06-01 05:01:15')
1696
+ >>> ts + BMonthBegin(2)
1697
+ Timestamp('2020-07-01 05:01:15')
1698
+ >>> ts + BMonthBegin(-3)
1699
+ Timestamp('2020-03-02 05:01:15')
1613
1700
"""
1614
1701
_prefix = " BMS"
1615
1702
_day_opt = " business_start"
0 commit comments