Skip to content

Commit 10927a3

Browse files
committed
Merge pull request #5814 from jorisvandenbossche/doc-dtindex-attribute
DOC: add way to document DatetimeIndex field attributes
2 parents 97860a1 + 25511c0 commit 10927a3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/tseries/index.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _utc():
3636
# -------- some conversion wrapper functions
3737

3838

39-
def _field_accessor(name, field):
39+
def _field_accessor(name, field, docstring=None):
4040
def f(self):
4141
values = self.asi8
4242
if self.tz is not None:
@@ -45,6 +45,7 @@ def f(self):
4545
values = self._local_timestamps()
4646
return tslib.get_date_field(values, field)
4747
f.__name__ = name
48+
f.__doc__ = docstring
4849
return property(f)
4950

5051

@@ -1398,7 +1399,7 @@ def freqstr(self):
13981399
return self.offset.freqstr
13991400

14001401
year = _field_accessor('year', 'Y')
1401-
month = _field_accessor('month', 'M')
1402+
month = _field_accessor('month', 'M', "The month as January=1, December=12")
14021403
day = _field_accessor('day', 'D')
14031404
hour = _field_accessor('hour', 'h')
14041405
minute = _field_accessor('minute', 'm')
@@ -1407,7 +1408,8 @@ def freqstr(self):
14071408
nanosecond = _field_accessor('nanosecond', 'ns')
14081409
weekofyear = _field_accessor('weekofyear', 'woy')
14091410
week = weekofyear
1410-
dayofweek = _field_accessor('dayofweek', 'dow')
1411+
dayofweek = _field_accessor('dayofweek', 'dow',
1412+
"The day of the week with Monday=0, Sunday=6")
14111413
weekday = dayofweek
14121414
dayofyear = _field_accessor('dayofyear', 'doy')
14131415
quarter = _field_accessor('quarter', 'q')

0 commit comments

Comments
 (0)