@@ -1494,11 +1494,29 @@ cdef class BusinessDay(BusinessMixin):
1494
1494
"""
1495
1495
DateOffset subclass representing possibly n business days.
1496
1496
1497
+ Parameters
1498
+ ----------
1499
+ n : int, default 1
1500
+ The number of days represented.
1501
+ normalize : bool, default False
1502
+ Normalize start/end dates to midnight.
1503
+
1497
1504
Examples
1498
1505
--------
1499
- >>> ts = pd.Timestamp(2022, 8, 5)
1500
- >>> ts + pd.offsets.BusinessDay()
1501
- Timestamp('2022-08-08 00:00:00')
1506
+ You can use the parameter ``n`` to represent a shift of n business days.
1507
+
1508
+ >>> ts = pd.Timestamp(2022, 12, 9, 15)
1509
+ >>> ts.strftime('%a %d %b %Y %H :%M ')
1510
+ 'Fri 09 Dec 2022 15:00'
1511
+ >>> (ts + pd.offsets.BusinessDay(n=5)).strftime('%a %d %b %Y %H :%M ')
1512
+ 'Fri 16 Dec 2022 15:00'
1513
+
1514
+ Passing the parameter ``normalize`` equal to True, you shift the start
1515
+ of the next business day to midnight.
1516
+
1517
+ >>> ts = pd.Timestamp(2022, 12, 9, 15)
1518
+ >>> ts + pd.offsets.BusinessDay(normalize=True)
1519
+ Timestamp('2022-12-12 00:00:00')
1502
1520
"""
1503
1521
_period_dtype_code = PeriodDtypeCode.B
1504
1522
_prefix = " B"
@@ -1610,29 +1628,53 @@ cdef class BusinessHour(BusinessMixin):
1610
1628
Parameters
1611
1629
----------
1612
1630
n : int, default 1
1613
- The number of months represented.
1631
+ The number of hours represented.
1614
1632
normalize : bool, default False
1615
1633
Normalize start/end dates to midnight before generating date range.
1616
- weekmask : str, Default 'Mon Tue Wed Thu Fri'
1617
- Weekmask of valid business days, passed to ``numpy.busdaycalendar``.
1618
1634
start : str, time, or list of str/time, default "09:00"
1619
1635
Start time of your custom business hour in 24h format.
1620
1636
end : str, time, or list of str/time, default: "17:00"
1621
1637
End time of your custom business hour in 24h format.
1622
1638
1623
1639
Examples
1624
1640
--------
1625
- >>> from datetime import time
1641
+ You can use the parameter ``n`` to represent a shift of n hours.
1642
+
1643
+ >>> ts = pd.Timestamp(2022, 12, 9, 8)
1644
+ >>> ts + pd.offsets.BusinessHour(n=5)
1645
+ Timestamp('2022-12-09 14:00:00')
1646
+
1647
+ You can also change the start and the end of business hours.
1648
+
1626
1649
>>> ts = pd.Timestamp(2022, 8, 5, 16)
1627
- >>> ts + pd.offsets.BusinessHour()
1628
- Timestamp('2022-08-08 09:00:00')
1629
1650
>>> ts + pd.offsets.BusinessHour(start="11:00")
1630
1651
Timestamp('2022-08-08 11:00:00')
1631
- >>> ts + pd.offsets.BusinessHour(end=time(19, 0))
1632
- Timestamp('2022-08-05 17:00:00')
1633
- >>> ts + pd.offsets.BusinessHour(start=[time(9, 0), "20:00"],
1634
- ... end=["17:00", time(22, 0)])
1635
- Timestamp('2022-08-05 20:00:00')
1652
+
1653
+ >>> from datetime import time as dt_time
1654
+ >>> ts = pd.Timestamp(2022, 8, 5, 22)
1655
+ >>> ts + pd.offsets.BusinessHour(end=dt_time(19, 0))
1656
+ Timestamp('2022-08-08 10:00:00')
1657
+
1658
+ Passing the parameter ``normalize`` equal to True, you shift the start
1659
+ of the next business hour to midnight.
1660
+
1661
+ >>> ts = pd.Timestamp(2022, 12, 9, 8)
1662
+ >>> ts + pd.offsets.BusinessHour(normalize=True)
1663
+ Timestamp('2022-12-09 00:00:00')
1664
+
1665
+ You can divide your business day hours into several parts.
1666
+
1667
+ >>> import datetime as dt
1668
+ >>> freq = pd.offsets.BusinessHour(start=["06:00", "10:00", "15:00"],
1669
+ ... end=["08:00", "12:00", "17:00"])
1670
+ >>> pd.date_range(dt.datetime(2022, 12, 9), dt.datetime(2022, 12, 13), freq=freq)
1671
+ DatetimeIndex(['2022-12-09 06:00:00', '2022-12-09 07:00:00',
1672
+ '2022-12-09 10:00:00', '2022-12-09 11:00:00',
1673
+ '2022-12-09 15:00:00', '2022-12-09 16:00:00',
1674
+ '2022-12-12 06:00:00', '2022-12-12 07:00:00',
1675
+ '2022-12-12 10:00:00', '2022-12-12 11:00:00',
1676
+ '2022-12-12 15:00:00', '2022-12-12 16:00:00'],
1677
+ dtype='datetime64[ns]', freq='BH')
1636
1678
"""
1637
1679
1638
1680
_prefix = " BH"
@@ -3536,6 +3578,7 @@ cdef class CustomBusinessDay(BusinessDay):
3536
3578
Parameters
3537
3579
----------
3538
3580
n : int, default 1
3581
+ The number of days represented.
3539
3582
normalize : bool, default False
3540
3583
Normalize start/end dates to midnight before generating date range.
3541
3584
weekmask : str, Default 'Mon Tue Wed Thu Fri'
@@ -3624,7 +3667,7 @@ cdef class CustomBusinessHour(BusinessHour):
3624
3667
Parameters
3625
3668
----------
3626
3669
n : int, default 1
3627
- The number of months represented.
3670
+ The number of hours represented.
3628
3671
normalize : bool, default False
3629
3672
Normalize start/end dates to midnight before generating date range.
3630
3673
weekmask : str, Default 'Mon Tue Wed Thu Fri'
@@ -3662,7 +3705,7 @@ cdef class CustomBusinessHour(BusinessHour):
3662
3705
>>> ts + pd.offsets.CustomBusinessHour(end=dt_time(19, 0))
3663
3706
Timestamp('2022-08-08 10:00:00')
3664
3707
3665
- In the example below we divide our business day hours into several parts.
3708
+ You can divide your business day hours into several parts.
3666
3709
3667
3710
>>> import datetime as dt
3668
3711
>>> freq = pd.offsets.CustomBusinessHour(start=["06:00", "10:00", "15:00"],
@@ -3692,7 +3735,7 @@ cdef class CustomBusinessHour(BusinessHour):
3692
3735
'Fri 16 Dec 2022 12:00'],
3693
3736
dtype='object')
3694
3737
3695
- In the example below we define custom holidays by using NumPy business day calendar .
3738
+ Using NumPy business day calendar you can define custom holidays.
3696
3739
3697
3740
>>> import datetime as dt
3698
3741
>>> bdc = np.busdaycalendar(holidays=['2022-12-12', '2022-12-14'])
0 commit comments