@@ -589,13 +589,36 @@ cdef class BaseOffset:
589
589
590
590
@property
591
591
def rule_code(self ) -> str:
592
+ """
593
+ Return a string representing the base frequency.
594
+
595
+ See Also
596
+ --------
597
+ tseries.offsets.Hour.rule_code : Returns a string representing the base frequency of 'h'.
598
+ tseries.offsets.Day.rule_code : Returns a string representing the base frequency of 'D'.
599
+
600
+ Examples
601
+ --------
602
+ >>> pd.offsets.Hour().rule_code
603
+ 'h'
604
+
605
+ >>> pd.offsets.Week(5).rule_code
606
+ 'W'
607
+ """
592
608
return self._prefix
593
609
594
610
@cache_readonly
595
611
def freqstr(self ) -> str:
596
612
"""
597
613
Return a string representing the frequency.
598
614
615
+ See Also
616
+ --------
617
+ tseries.offsets.BusinessDay.freqstr : Return a string representing an offset frequency in Business Days.
618
+ tseries.offsets.BusinessHour.freqstr : Return a string representing an offset frequency in Business Hours.
619
+ tseries.offsets.Week.freqstr : Return a string representing an offset frequency in Weeks.
620
+ tseries.offsets.Hour.freqstr : Return a string representing an offset frequency in Hours.
621
+
599
622
Examples
600
623
--------
601
624
>>> pd.DateOffset(5).freqstr
@@ -773,6 +796,26 @@ cdef class BaseOffset:
773
796
774
797
@property
775
798
def nanos (self ):
799
+ """
800
+ Returns a ValueError becuase the frequency is non-fixed.
801
+
802
+ Raises
803
+ ------
804
+ ValueError
805
+ If the frequency is non-fixed.
806
+
807
+ See Also
808
+ --------
809
+ tseries.offsets.WeekOfMonth.nanos : Raises a ValueError becuase the frequency is non-fixed.
810
+ tseries.offsets.YearBegin.nanos : Raises a ValueError becuase the frequency is non-fixed.
811
+ tseries.offsets.Hour.nanos : Returns an integer of the total number of nanoseconds.
812
+ tseries.offsets.Day.nanos : Returns an integer of the total number of nanoseconds.
813
+
814
+ Examples
815
+ --------
816
+ >>> pd.offsets.Week(n=1).nanos
817
+ ValueError: <5 * Weeks: weekday=None> is a non-fixed frequency
818
+ """
776
819
raise ValueError (f" {self} is a non-fixed frequency" )
777
820
778
821
# ------------------------------------------------------------------
@@ -980,12 +1023,14 @@ cdef class Tick(SingleConstructorOffset):
980
1023
@property
981
1024
def nanos (self ) -> int64_t:
982
1025
"""
983
- Return an integer of the total number of nanoseconds.
1026
+ Returns an integer of the total number of nanoseconds.
984
1027
985
- Raises
986
- ------
987
- ValueError
988
- If the frequency is non-fixed.
1028
+ See Also
1029
+ --------
1030
+ tseries.offsets.Hour.nanos : Returns an integer of the total number of nanoseconds.
1031
+ tseries.offsets.Day.nanos : Returns an integer of the total number of nanoseconds.
1032
+ tseries.offsets.WeekOfMonth.nanos : Raises a ValueError becuase the frequency is non-fixed.
1033
+ tseries.offsets.YearBegin.nanos : Raises a ValueError becuase the frequency is non-fixed.
989
1034
990
1035
Examples
991
1036
--------
@@ -2420,6 +2465,22 @@ cdef class WeekOfMonthMixin(SingleConstructorOffset):
2420
2465
2421
2466
@property
2422
2467
def rule_code (self ) -> str:
2468
+ """
2469
+ Return a string representing the base frequency.
2470
+
2471
+ See Also
2472
+ --------
2473
+ tseries.offsets.Hour.rule_code : Returns a string representing the base frequency of 'h'.
2474
+ tseries.offsets.Day.rule_code : Returns a string representing the base frequency of 'D'.
2475
+
2476
+ Examples
2477
+ --------
2478
+ >>> pd.offsets.Week(5).rule_code
2479
+ 'W'
2480
+
2481
+ >>> pd.offsets.WeekOfMonth(n = 1 , week = 0 , weekday = 0 ).rule_code
2482
+ 'WOM-1MON'
2483
+ """
2423
2484
weekday = int_to_weekday.get(self .weekday, " " )
2424
2485
if self.week == -1:
2425
2486
# LastWeekOfMonth
@@ -2466,6 +2527,22 @@ cdef class YearOffset(SingleConstructorOffset):
2466
2527
2467
2528
@property
2468
2529
def rule_code (self ) -> str:
2530
+ """
2531
+ Return a string representing the base frequency.
2532
+
2533
+ See Also
2534
+ --------
2535
+ tseries.offsets.Hour.rule_code : Returns a string representing the base frequency of 'h'.
2536
+ tseries.offsets.Day.rule_code : Returns a string representing the base frequency of 'D'.
2537
+
2538
+ Examples
2539
+ --------
2540
+ >>> pd.tseries.offsets.YearBegin(n = 1 , month = 2 ).rule_code
2541
+ 'YS-FEB'
2542
+
2543
+ >>> pd.tseries.offsets.YearEnd(n = 1 , month = 6 ).rule_code
2544
+ 'YE-JUN'
2545
+ """
2469
2546
month = MONTH_ALIASES[self .month]
2470
2547
return f"{self._prefix}-{month}"
2471
2548
@@ -3452,6 +3529,22 @@ cdef class Week(SingleConstructorOffset):
3452
3529
3453
3530
@property
3454
3531
def rule_code (self ) -> str:
3532
+ """
3533
+ Return a string representing the base frequency.
3534
+
3535
+ See Also
3536
+ --------
3537
+ tseries.offsets.Hour.name : Returns a string representing the base frequency of 'h'.
3538
+ tseries.offsets.Day.name : Returns a string representing the base frequency of 'D'.
3539
+
3540
+ Examples
3541
+ --------
3542
+ >>> pd.offsets.Hour().rule_code
3543
+ 'h'
3544
+
3545
+ >>> pd.offsets.Week(5).rule_code
3546
+ 'W'
3547
+ """
3455
3548
suffix = " "
3456
3549
if self.weekday is not None:
3457
3550
weekday = int_to_weekday[self .weekday]
0 commit comments