diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 2e086c8ce8c34..6a4ca0ab4147a 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1414,17 +1414,69 @@ def date(self): return tslib.ints_to_pydatetime(timestamps, box="date") - year = _field_accessor("year", "Y", "The year of the datetime.") - month = _field_accessor("month", "M", "The month as January=1, December=12. ") - day = _field_accessor("day", "D", "The days of the datetime.") - hour = _field_accessor("hour", "h", "The hours of the datetime.") - minute = _field_accessor("minute", "m", "The minutes of the datetime.") - second = _field_accessor("second", "s", "The seconds of the datetime.") + year = _field_accessor( + "year", + "Y", + """ + The year of the datetime. + """, + ) + month = _field_accessor( + "month", + "M", + """ + The month as January=1, December=12. + """, + ) + day = _field_accessor( + "day", + "D", + """ + The month as January=1, December=12. + """, + ) + hour = _field_accessor( + "hour", + "h", + """ + The hours of the datetime. + """, + ) + minute = _field_accessor( + "minute", + "m", + """ + The minutes of the datetime. + """, + ) + second = _field_accessor( + "second", + "s", + """ + The seconds of the datetime. + """, + ) microsecond = _field_accessor( - "microsecond", "us", "The microseconds of the datetime." + "microsecond", + "us", + """ + The microseconds of the datetime. + """, + ) + nanosecond = _field_accessor( + "nanosecond", + "ns", + """ + The nanoseconds of the datetime. + """, + ) + weekofyear = _field_accessor( + "weekofyear", + "woy", + """ + The week ordinal of the year. + """, ) - nanosecond = _field_accessor("nanosecond", "ns", "The nanoseconds of the datetime.") - weekofyear = _field_accessor("weekofyear", "woy", "The week ordinal of the year.") week = weekofyear _dayofweek_doc = """ The day of the week with Monday=0, Sunday=6. @@ -1466,13 +1518,31 @@ def date(self): weekday_name = _field_accessor( "weekday_name", "weekday_name", - "The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0", + """ + The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0 + """, ) - dayofyear = _field_accessor("dayofyear", "doy", "The ordinal day of the year.") - quarter = _field_accessor("quarter", "q", "The quarter of the date.") + dayofyear = _field_accessor( + "dayofyear", + "doy", + """ + The ordinal day of the year. + """, + ) + quarter = _field_accessor( + "quarter", + "q", + """ + The quarter of the date. + """, + ) days_in_month = _field_accessor( - "days_in_month", "dim", "The number of days in the month." + "days_in_month", + "dim", + """ + The number of days in the month. + """, ) daysinmonth = days_in_month _is_month_doc = """ diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index c290391278def..91dd853e78c77 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -342,25 +342,85 @@ def __array__(self, dtype=None): # -------------------------------------------------------------------- # Vectorized analogues of Period properties - year = _field_accessor("year", 0, "The year of the period") - month = _field_accessor("month", 3, "The month as January=1, December=12") - day = _field_accessor("day", 4, "The days of the period") - hour = _field_accessor("hour", 5, "The hour of the period") - minute = _field_accessor("minute", 6, "The minute of the period") - second = _field_accessor("second", 7, "The second of the period") - weekofyear = _field_accessor("week", 8, "The week ordinal of the year") + year = _field_accessor( + "year", + 0, + """ + The year of the period. + """, + ) + month = _field_accessor( + "month", + 3, + """ + The month as January=1, December=12. + """, + ) + day = _field_accessor( + "day", + 4, + """ + The days of the period. + """, + ) + hour = _field_accessor( + "hour", + 5, + """ + The hour of the period. + """, + ) + minute = _field_accessor( + "minute", + 6, + """ + The minute of the period. + """, + ) + second = _field_accessor( + "second", + 7, + """ + The second of the period. + """, + ) + weekofyear = _field_accessor( + "week", + 8, + """ + The week ordinal of the year. + """, + ) week = weekofyear dayofweek = _field_accessor( - "dayofweek", 10, "The day of the week with Monday=0, Sunday=6" + "dayofweek", + 10, + """ + The day of the week with Monday=0, Sunday=6. + """, ) weekday = dayofweek dayofyear = day_of_year = _field_accessor( - "dayofyear", 9, "The ordinal day of the year" + "dayofyear", + 9, + """ + The ordinal day of the year. + """, + ) + quarter = _field_accessor( + "quarter", + 2, + """ + The quarter of the date. + """, ) - quarter = _field_accessor("quarter", 2, "The quarter of the date") qyear = _field_accessor("qyear", 1) days_in_month = _field_accessor( - "days_in_month", 11, "The number of days in the month" + "days_in_month", + 11, + """ + The number of days in the month. + """, ) daysinmonth = days_in_month