Skip to content

Commit 42193b4

Browse files
saurav-chakravortyPingviinituutti
authored andcommitted
DOC: Updates to Timestamp document (pandas-dev#25163)
1 parent 7f7f485 commit 42193b4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

pandas/_libs/tslibs/timestamps.pyx

+45
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ cdef class _Timestamp(datetime):
504504

505505
@property
506506
def asm8(self):
507+
"""
508+
Return numpy datetime64 format in nanoseconds.
509+
"""
507510
return np.datetime64(self.value, 'ns')
508511

509512
@property
@@ -570,15 +573,18 @@ class Timestamp(_Timestamp):
570573
Using the primary calling convention:
571574
572575
This converts a datetime-like string
576+
573577
>>> pd.Timestamp('2017-01-01T12')
574578
Timestamp('2017-01-01 12:00:00')
575579
576580
This converts a float representing a Unix epoch in units of seconds
581+
577582
>>> pd.Timestamp(1513393355.5, unit='s')
578583
Timestamp('2017-12-16 03:02:35.500000')
579584
580585
This converts an int representing a Unix-epoch in units of seconds
581586
and for a particular timezone
587+
582588
>>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific')
583589
Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific')
584590
@@ -934,6 +940,9 @@ class Timestamp(_Timestamp):
934940

935941
@property
936942
def dayofweek(self):
943+
"""
944+
Return day of whe week.
945+
"""
937946
return self.weekday()
938947

939948
def day_name(self, locale=None):
@@ -983,72 +992,108 @@ class Timestamp(_Timestamp):
983992

984993
@property
985994
def dayofyear(self):
995+
"""
996+
Return the day of the year.
997+
"""
986998
return ccalendar.get_day_of_year(self.year, self.month, self.day)
987999

9881000
@property
9891001
def week(self):
1002+
"""
1003+
Return the week number of the year.
1004+
"""
9901005
return ccalendar.get_week_of_year(self.year, self.month, self.day)
9911006

9921007
weekofyear = week
9931008

9941009
@property
9951010
def quarter(self):
1011+
"""
1012+
Return the quarter of the year.
1013+
"""
9961014
return ((self.month - 1) // 3) + 1
9971015

9981016
@property
9991017
def days_in_month(self):
1018+
"""
1019+
Return the number of days in the month.
1020+
"""
10001021
return ccalendar.get_days_in_month(self.year, self.month)
10011022

10021023
daysinmonth = days_in_month
10031024

10041025
@property
10051026
def freqstr(self):
1027+
"""
1028+
Return the total number of days in the month.
1029+
"""
10061030
return getattr(self.freq, 'freqstr', self.freq)
10071031

10081032
@property
10091033
def is_month_start(self):
1034+
"""
1035+
Return True if date is first day of month.
1036+
"""
10101037
if self.freq is None:
10111038
# fast-path for non-business frequencies
10121039
return self.day == 1
10131040
return self._get_start_end_field('is_month_start')
10141041

10151042
@property
10161043
def is_month_end(self):
1044+
"""
1045+
Return True if date is last day of month.
1046+
"""
10171047
if self.freq is None:
10181048
# fast-path for non-business frequencies
10191049
return self.day == self.days_in_month
10201050
return self._get_start_end_field('is_month_end')
10211051

10221052
@property
10231053
def is_quarter_start(self):
1054+
"""
1055+
Return True if date is first day of the quarter.
1056+
"""
10241057
if self.freq is None:
10251058
# fast-path for non-business frequencies
10261059
return self.day == 1 and self.month % 3 == 1
10271060
return self._get_start_end_field('is_quarter_start')
10281061

10291062
@property
10301063
def is_quarter_end(self):
1064+
"""
1065+
Return True if date is last day of the quarter.
1066+
"""
10311067
if self.freq is None:
10321068
# fast-path for non-business frequencies
10331069
return (self.month % 3) == 0 and self.day == self.days_in_month
10341070
return self._get_start_end_field('is_quarter_end')
10351071

10361072
@property
10371073
def is_year_start(self):
1074+
"""
1075+
Return True if date is first day of the year.
1076+
"""
10381077
if self.freq is None:
10391078
# fast-path for non-business frequencies
10401079
return self.day == self.month == 1
10411080
return self._get_start_end_field('is_year_start')
10421081

10431082
@property
10441083
def is_year_end(self):
1084+
"""
1085+
Return True if date is last day of the year.
1086+
"""
10451087
if self.freq is None:
10461088
# fast-path for non-business frequencies
10471089
return self.month == 12 and self.day == 31
10481090
return self._get_start_end_field('is_year_end')
10491091

10501092
@property
10511093
def is_leap_year(self):
1094+
"""
1095+
Return True if year is a leap year.
1096+
"""
10521097
return bool(ccalendar.is_leapyear(self.year))
10531098

10541099
def tz_localize(self, tz, ambiguous='raise', nonexistent='raise',

0 commit comments

Comments
 (0)