@@ -504,6 +504,9 @@ cdef class _Timestamp(datetime):
504
504
505
505
@property
506
506
def asm8 (self ):
507
+ """
508
+ Return numpy datetime64 format in nanoseconds.
509
+ """
507
510
return np.datetime64(self .value, ' ns' )
508
511
509
512
@property
@@ -570,15 +573,18 @@ class Timestamp(_Timestamp):
570
573
Using the primary calling convention:
571
574
572
575
This converts a datetime-like string
576
+
573
577
>>> pd.Timestamp('2017-01-01T12')
574
578
Timestamp('2017-01-01 12:00:00')
575
579
576
580
This converts a float representing a Unix epoch in units of seconds
581
+
577
582
>>> pd.Timestamp(1513393355.5, unit='s')
578
583
Timestamp('2017-12-16 03:02:35.500000')
579
584
580
585
This converts an int representing a Unix-epoch in units of seconds
581
586
and for a particular timezone
587
+
582
588
>>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific')
583
589
Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific')
584
590
@@ -934,6 +940,9 @@ class Timestamp(_Timestamp):
934
940
935
941
@property
936
942
def dayofweek (self ):
943
+ """
944
+ Return day of whe week.
945
+ """
937
946
return self .weekday()
938
947
939
948
def day_name (self , locale = None ):
@@ -983,72 +992,108 @@ class Timestamp(_Timestamp):
983
992
984
993
@property
985
994
def dayofyear (self ):
995
+ """
996
+ Return the day of the year.
997
+ """
986
998
return ccalendar.get_day_of_year(self .year, self .month, self .day)
987
999
988
1000
@property
989
1001
def week (self ):
1002
+ """
1003
+ Return the week number of the year.
1004
+ """
990
1005
return ccalendar.get_week_of_year(self .year, self .month, self .day)
991
1006
992
1007
weekofyear = week
993
1008
994
1009
@property
995
1010
def quarter (self ):
1011
+ """
1012
+ Return the quarter of the year.
1013
+ """
996
1014
return ((self .month - 1 ) // 3 ) + 1
997
1015
998
1016
@property
999
1017
def days_in_month (self ):
1018
+ """
1019
+ Return the number of days in the month.
1020
+ """
1000
1021
return ccalendar.get_days_in_month(self .year, self .month)
1001
1022
1002
1023
daysinmonth = days_in_month
1003
1024
1004
1025
@property
1005
1026
def freqstr (self ):
1027
+ """
1028
+ Return the total number of days in the month.
1029
+ """
1006
1030
return getattr (self .freq, ' freqstr' , self .freq)
1007
1031
1008
1032
@property
1009
1033
def is_month_start (self ):
1034
+ """
1035
+ Return True if date is first day of month.
1036
+ """
1010
1037
if self .freq is None :
1011
1038
# fast-path for non-business frequencies
1012
1039
return self .day == 1
1013
1040
return self ._get_start_end_field(' is_month_start' )
1014
1041
1015
1042
@property
1016
1043
def is_month_end (self ):
1044
+ """
1045
+ Return True if date is last day of month.
1046
+ """
1017
1047
if self .freq is None :
1018
1048
# fast-path for non-business frequencies
1019
1049
return self .day == self .days_in_month
1020
1050
return self ._get_start_end_field(' is_month_end' )
1021
1051
1022
1052
@property
1023
1053
def is_quarter_start (self ):
1054
+ """
1055
+ Return True if date is first day of the quarter.
1056
+ """
1024
1057
if self .freq is None :
1025
1058
# fast-path for non-business frequencies
1026
1059
return self .day == 1 and self .month % 3 == 1
1027
1060
return self ._get_start_end_field(' is_quarter_start' )
1028
1061
1029
1062
@property
1030
1063
def is_quarter_end (self ):
1064
+ """
1065
+ Return True if date is last day of the quarter.
1066
+ """
1031
1067
if self .freq is None :
1032
1068
# fast-path for non-business frequencies
1033
1069
return (self .month % 3 ) == 0 and self .day == self .days_in_month
1034
1070
return self ._get_start_end_field(' is_quarter_end' )
1035
1071
1036
1072
@property
1037
1073
def is_year_start (self ):
1074
+ """
1075
+ Return True if date is first day of the year.
1076
+ """
1038
1077
if self .freq is None :
1039
1078
# fast-path for non-business frequencies
1040
1079
return self .day == self .month == 1
1041
1080
return self ._get_start_end_field(' is_year_start' )
1042
1081
1043
1082
@property
1044
1083
def is_year_end (self ):
1084
+ """
1085
+ Return True if date is last day of the year.
1086
+ """
1045
1087
if self .freq is None :
1046
1088
# fast-path for non-business frequencies
1047
1089
return self .month == 12 and self .day == 31
1048
1090
return self ._get_start_end_field(' is_year_end' )
1049
1091
1050
1092
@property
1051
1093
def is_leap_year (self ):
1094
+ """
1095
+ Return True if year is a leap year.
1096
+ """
1052
1097
return bool (ccalendar.is_leapyear(self .year))
1053
1098
1054
1099
def tz_localize (self , tz , ambiguous = ' raise' , nonexistent = ' raise' ,
0 commit comments