@@ -292,9 +292,7 @@ def _from_name(cls, suffix=None):
292
292
293
293
294
294
class BusinessDay (CacheableOffset , SingleConstructorOffset ):
295
- """
296
- DateOffset subclass representing possibly n business days
297
- """
295
+ """Business day (weekday)"""
298
296
_prefix = 'B'
299
297
300
298
def __init__ (self , n = 1 , ** kwds ):
@@ -425,7 +423,8 @@ def onOffset(cls, dt):
425
423
426
424
427
425
class CustomBusinessDay (BusinessDay ):
428
- """
426
+ """Custom representation **EXPERIMENTAL**
427
+
429
428
**EXPERIMENTAL** DateOffset subclass representing possibly n business days
430
429
excluding holidays
431
430
@@ -445,6 +444,7 @@ class CustomBusinessDay(BusinessDay):
445
444
holidays : list
446
445
list/array of dates to exclude from the set of valid business days,
447
446
passed to ``numpy.busdaycalendar``
447
+
448
448
"""
449
449
450
450
_cacheable = False
@@ -547,7 +547,7 @@ def name(self):
547
547
548
548
549
549
class MonthEnd (CacheableOffset , MonthOffset ):
550
- """DateOffset of one month end"""
550
+ """Calendar month end date """
551
551
552
552
def apply (self , other ):
553
553
other = datetime (other .year , other .month , other .day ,
@@ -571,7 +571,7 @@ def onOffset(cls, dt):
571
571
572
572
573
573
class MonthBegin (CacheableOffset , MonthOffset ):
574
- """DateOffset of one month at beginning """
574
+ """Calendar month begin date """
575
575
576
576
def apply (self , other ):
577
577
n = self .n
@@ -590,7 +590,7 @@ def onOffset(cls, dt):
590
590
591
591
592
592
class BusinessMonthEnd (CacheableOffset , MonthOffset ):
593
- """DateOffset increments between business EOM dates"""
593
+ """Business month end dates"""
594
594
595
595
def isAnchored (self ):
596
596
return (self .n == 1 )
@@ -618,7 +618,7 @@ def apply(self, other):
618
618
619
619
620
620
class BusinessMonthBegin (CacheableOffset , MonthOffset ):
621
- """DateOffset of one business month at beginning """
621
+ """Business month begin date """
622
622
623
623
def apply (self , other ):
624
624
n = self .n
@@ -653,13 +653,13 @@ def onOffset(cls, dt):
653
653
654
654
655
655
class Week (CacheableOffset , DateOffset ):
656
- """
657
- Weekly offset
656
+ """Week, optionally anchored on day of the week
658
657
659
658
Parameters
660
659
----------
661
660
weekday : int, default None
662
661
Always generate specific day of week. 0 for Monday
662
+
663
663
"""
664
664
665
665
def __init__ (self , n = 1 , ** kwds ):
@@ -720,6 +720,7 @@ def _from_name(cls, suffix=None):
720
720
weekday = _weekday_to_int [suffix ]
721
721
return cls (weekday = weekday )
722
722
723
+
723
724
class WeekDay (object ):
724
725
MON = 0
725
726
TUE = 1
@@ -743,8 +744,7 @@ class WeekDay(object):
743
744
744
745
745
746
class WeekOfMonth (CacheableOffset , DateOffset ):
746
- """
747
- Describes monthly dates like "the Tuesday of the 2nd week of each month"
747
+ """Dates like "Tuesday of the 2nd week each month"
748
748
749
749
Parameters
750
750
----------
@@ -759,6 +759,7 @@ class WeekOfMonth(CacheableOffset, DateOffset):
759
759
4: Fridays
760
760
5: Saturdays
761
761
6: Sundays
762
+
762
763
"""
763
764
764
765
def __init__ (self , n = 1 , ** kwds ):
@@ -828,9 +829,9 @@ def _from_name(cls, suffix=None):
828
829
weekday = _weekday_to_int [suffix [1 :]]
829
830
return cls (week = week , weekday = weekday )
830
831
832
+
831
833
class LastWeekOfMonth (CacheableOffset , DateOffset ):
832
- """
833
- Describes monthly dates in last week of month like "the last Tuesday of each month"
834
+ """Dates like "last Tuesday of the month"
834
835
835
836
Parameters
836
837
----------
@@ -843,7 +844,9 @@ class LastWeekOfMonth(CacheableOffset, DateOffset):
843
844
4: Fridays
844
845
5: Saturdays
845
846
6: Sundays
847
+
846
848
"""
849
+
847
850
def __init__ (self , n = 1 , ** kwds ):
848
851
self .n = n
849
852
self .weekday = kwds ['weekday' ]
@@ -939,10 +942,12 @@ def rule_code(self):
939
942
940
943
941
944
class BQuarterEnd (CacheableOffset , QuarterOffset ):
942
- """DateOffset increments between business Quarter dates
945
+ """Business quarter end date
946
+
943
947
startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ...
944
948
startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ...
945
949
startingMonth = 3 corresponds to dates like 3/30/2007, 6/29/2007, ...
950
+
946
951
"""
947
952
_outputName = 'BusinessQuarterEnd'
948
953
_default_startingMonth = 3
@@ -977,9 +982,9 @@ def onOffset(self, dt):
977
982
modMonth = (dt .month - self .startingMonth ) % 3
978
983
return BMonthEnd ().onOffset (dt ) and modMonth == 0
979
984
985
+
980
986
class FY5253 (CacheableOffset , DateOffset ):
981
- """
982
- Describes 52-53 week fiscal year. This is also known as a 4-4-5 calendar.
987
+ """End date, 52-53 week fiscal year (4-4-5 calendar)
983
988
984
989
It is used by companies that desire that their
985
990
fiscal year always end on the same day of the week.
@@ -1013,6 +1018,7 @@ class FY5253(CacheableOffset, DateOffset):
1013
1018
startingMonth : The month in which fiscal years end. {1, 2, ... 12}
1014
1019
variation : str
1015
1020
{"nearest", "last"} for "LastOfMonth" or "NearestEndMonth"
1021
+
1016
1022
"""
1017
1023
1018
1024
_prefix = 'RE'
@@ -1142,13 +1148,12 @@ def _parse_suffix(cls, varion_code, startingMonth_code, weekday_code):
1142
1148
def _from_name (cls , * args ):
1143
1149
return cls (** cls ._parse_suffix (* args ))
1144
1150
1151
+
1145
1152
class FY5253Quarter (CacheableOffset , DateOffset ):
1146
- """
1147
- DateOffset increments between business quarter dates
1148
- for 52-53 week fiscal year (also known as a 4-4-5 calendar).
1153
+ """Quarter end, 52-53 week fiscal year (4-4-5 calendar)
1149
1154
1150
- It is used by companies that desire that their
1151
- fiscal year always end on the same day of the week.
1155
+ The 4-4-5 calendar is used by companies that desire that
1156
+ their fiscal year always end on the same day of the week.
1152
1157
1153
1158
It is a method of managing accounting periods.
1154
1159
It is a common calendar structure for some industries,
@@ -1184,6 +1189,7 @@ class FY5253Quarter(CacheableOffset, DateOffset):
1184
1189
or 14 week when needed. {1,2,3,4}
1185
1190
variation : str
1186
1191
{"nearest", "last"} for "LastOfMonth" or "NearestEndMonth"
1192
+
1187
1193
"""
1188
1194
1189
1195
_prefix = 'REQ'
@@ -1311,6 +1317,8 @@ def _from_name(cls, *args):
1311
1317
1312
1318
# TODO: This is basically the same as BQuarterEnd
1313
1319
class BQuarterBegin (CacheableOffset , QuarterOffset ):
1320
+ """Business quarter begin date"""
1321
+
1314
1322
_outputName = "BusinessQuarterBegin"
1315
1323
# I suspect this is wrong for *all* of them.
1316
1324
_default_startingMonth = 3
@@ -1348,7 +1356,8 @@ def apply(self, other):
1348
1356
1349
1357
1350
1358
class QuarterEnd (CacheableOffset , QuarterOffset ):
1351
- """DateOffset increments between business Quarter dates
1359
+ """Calendar quarter end date
1360
+
1352
1361
startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ...
1353
1362
startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ...
1354
1363
startingMonth = 3 corresponds to dates like 3/31/2007, 6/30/2007, ...
@@ -1389,6 +1398,8 @@ def onOffset(self, dt):
1389
1398
1390
1399
1391
1400
class QuarterBegin (CacheableOffset , QuarterOffset ):
1401
+ """Calendar quarter begin date"""
1402
+
1392
1403
_outputName = 'QuarterBegin'
1393
1404
_default_startingMonth = 3
1394
1405
_from_name_startingMonth = 1
@@ -1441,7 +1452,8 @@ def rule_code(self):
1441
1452
1442
1453
1443
1454
class BYearEnd (CacheableOffset , YearOffset ):
1444
- """DateOffset increments between business EOM dates"""
1455
+ """Business year end date"""
1456
+
1445
1457
_outputName = 'BusinessYearEnd'
1446
1458
_default_month = 12
1447
1459
_prefix = 'BA'
@@ -1478,7 +1490,8 @@ def apply(self, other):
1478
1490
1479
1491
1480
1492
class BYearBegin (CacheableOffset , YearOffset ):
1481
- """DateOffset increments between business year begin dates"""
1493
+ """Business year begin date"""
1494
+
1482
1495
_outputName = 'BusinessYearBegin'
1483
1496
_default_month = 1
1484
1497
_prefix = 'BAS'
@@ -1510,7 +1523,8 @@ def apply(self, other):
1510
1523
1511
1524
1512
1525
class YearEnd (CacheableOffset , YearOffset ):
1513
- """DateOffset increments between calendar year ends"""
1526
+ """Calendar year end date"""
1527
+
1514
1528
_default_month = 12
1515
1529
_prefix = 'A'
1516
1530
@@ -1566,7 +1580,8 @@ def onOffset(self, dt):
1566
1580
1567
1581
1568
1582
class YearBegin (CacheableOffset , YearOffset ):
1569
- """DateOffset increments between calendar year begin dates"""
1583
+ """Calendar year begin date"""
1584
+
1570
1585
_default_month = 1
1571
1586
_prefix = 'AS'
1572
1587
@@ -1731,35 +1746,42 @@ def _delta_to_nanoseconds(delta):
1731
1746
1732
1747
1733
1748
class Day (CacheableOffset , Tick ):
1749
+ """One calendar day"""
1734
1750
_inc = timedelta (1 )
1735
1751
_prefix = 'D'
1736
1752
1737
1753
1738
1754
class Hour (Tick ):
1755
+ """One hour"""
1739
1756
_inc = timedelta (0 , 3600 )
1740
1757
_prefix = 'H'
1741
1758
1742
1759
1743
1760
class Minute (Tick ):
1761
+ """One minute"""
1744
1762
_inc = timedelta (0 , 60 )
1745
1763
_prefix = 'T'
1746
-
1764
+
1747
1765
1748
1766
class Second (Tick ):
1767
+ """One second"""
1749
1768
_inc = timedelta (0 , 1 )
1750
1769
_prefix = 'S'
1751
1770
1752
1771
1753
1772
class Milli (Tick ):
1773
+ """One millisecond"""
1754
1774
_prefix = 'L'
1755
1775
1756
1776
1757
1777
class Micro (Tick ):
1778
+ """One microsecond"""
1758
1779
_inc = timedelta (microseconds = 1 )
1759
1780
_prefix = 'U'
1760
1781
1761
1782
1762
1783
class Nano (Tick ):
1784
+ """One nanosecond"""
1763
1785
_inc = np .timedelta64 (1 , 'ns' ) if not _np_version_under1p7 else 1
1764
1786
_prefix = 'N'
1765
1787
@@ -1796,6 +1818,7 @@ def generate_range(start=None, end=None, periods=None,
1796
1818
start : datetime (default None)
1797
1819
end : datetime (default None)
1798
1820
periods : int, optional
1821
+ offset : DateOffset, default BusinessDay
1799
1822
time_rule : (legacy) name of DateOffset object to be used, optional
1800
1823
Corresponds with names expected by tseries.frequencies.get_offset
1801
1824
@@ -1875,6 +1898,11 @@ def generate_range(start=None, end=None, periods=None,
1875
1898
FY5253Quarter ,
1876
1899
])
1877
1900
1901
+ _alias_doc = 'Offset Aliases\n --------------\n ' + \
1902
+ '\n ' .join (sorted ([item .ljust (max ([len (s ) for s in __all__ ])+ 2 ) + \
1903
+ (locals ()[item ].__doc__ .split ('\n ' )[0 ].strip () or '<no docstring found>' ) \
1904
+ for item in __all__ ]))
1905
+
1878
1906
if not _np_version_under1p7 :
1879
1907
# Only 1.7+ supports nanosecond resolution
1880
1908
prefix_mapping ['N' ] = Nano
0 commit comments