Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: add way to document DatetimeIndex field attributes #5814

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _utc():
# -------- some conversion wrapper functions


def _field_accessor(name, field):
def _field_accessor(name, field, docstring=None):
def f(self):
values = self.asi8
if self.tz is not None:
Expand All @@ -45,6 +45,7 @@ def f(self):
values = self._local_timestamps()
return tslib.get_date_field(values, field)
f.__name__ = name
f.__doc__ = docstring
return property(f)


Expand Down Expand Up @@ -1398,7 +1399,7 @@ def freqstr(self):
return self.offset.freqstr

year = _field_accessor('year', 'Y')
month = _field_accessor('month', 'M')
month = _field_accessor('month', 'M', "The month as January=1, December=12")
day = _field_accessor('day', 'D')
hour = _field_accessor('hour', 'h')
minute = _field_accessor('minute', 'm')
Expand All @@ -1407,7 +1408,8 @@ def freqstr(self):
nanosecond = _field_accessor('nanosecond', 'ns')
weekofyear = _field_accessor('weekofyear', 'woy')
week = weekofyear
dayofweek = _field_accessor('dayofweek', 'dow')
dayofweek = _field_accessor('dayofweek', 'dow',
"The day of the week with Monday=0, Sunday=6")
weekday = dayofweek
dayofyear = _field_accessor('dayofyear', 'doy')
quarter = _field_accessor('quarter', 'q')
Expand Down