Skip to content

Commit 3fccf6a

Browse files
abkosarTomAugspurger
authored andcommitted
DOC: pandas.PeriodIndex and pandas.DateTimeIndex docstring fix (pandas-dev#27716)
1 parent 15b11c8 commit 3fccf6a

File tree

2 files changed

+154
-24
lines changed

2 files changed

+154
-24
lines changed

pandas/core/arrays/datetimes.py

+83-13
Original file line numberDiff line numberDiff line change
@@ -1414,17 +1414,69 @@ def date(self):
14141414

14151415
return tslib.ints_to_pydatetime(timestamps, box="date")
14161416

1417-
year = _field_accessor("year", "Y", "The year of the datetime.")
1418-
month = _field_accessor("month", "M", "The month as January=1, December=12. ")
1419-
day = _field_accessor("day", "D", "The days of the datetime.")
1420-
hour = _field_accessor("hour", "h", "The hours of the datetime.")
1421-
minute = _field_accessor("minute", "m", "The minutes of the datetime.")
1422-
second = _field_accessor("second", "s", "The seconds of the datetime.")
1417+
year = _field_accessor(
1418+
"year",
1419+
"Y",
1420+
"""
1421+
The year of the datetime.
1422+
""",
1423+
)
1424+
month = _field_accessor(
1425+
"month",
1426+
"M",
1427+
"""
1428+
The month as January=1, December=12.
1429+
""",
1430+
)
1431+
day = _field_accessor(
1432+
"day",
1433+
"D",
1434+
"""
1435+
The month as January=1, December=12.
1436+
""",
1437+
)
1438+
hour = _field_accessor(
1439+
"hour",
1440+
"h",
1441+
"""
1442+
The hours of the datetime.
1443+
""",
1444+
)
1445+
minute = _field_accessor(
1446+
"minute",
1447+
"m",
1448+
"""
1449+
The minutes of the datetime.
1450+
""",
1451+
)
1452+
second = _field_accessor(
1453+
"second",
1454+
"s",
1455+
"""
1456+
The seconds of the datetime.
1457+
""",
1458+
)
14231459
microsecond = _field_accessor(
1424-
"microsecond", "us", "The microseconds of the datetime."
1460+
"microsecond",
1461+
"us",
1462+
"""
1463+
The microseconds of the datetime.
1464+
""",
1465+
)
1466+
nanosecond = _field_accessor(
1467+
"nanosecond",
1468+
"ns",
1469+
"""
1470+
The nanoseconds of the datetime.
1471+
""",
1472+
)
1473+
weekofyear = _field_accessor(
1474+
"weekofyear",
1475+
"woy",
1476+
"""
1477+
The week ordinal of the year.
1478+
""",
14251479
)
1426-
nanosecond = _field_accessor("nanosecond", "ns", "The nanoseconds of the datetime.")
1427-
weekofyear = _field_accessor("weekofyear", "woy", "The week ordinal of the year.")
14281480
week = weekofyear
14291481
_dayofweek_doc = """
14301482
The day of the week with Monday=0, Sunday=6.
@@ -1466,13 +1518,31 @@ def date(self):
14661518
weekday_name = _field_accessor(
14671519
"weekday_name",
14681520
"weekday_name",
1469-
"The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0",
1521+
"""
1522+
The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0
1523+
""",
14701524
)
14711525

1472-
dayofyear = _field_accessor("dayofyear", "doy", "The ordinal day of the year.")
1473-
quarter = _field_accessor("quarter", "q", "The quarter of the date.")
1526+
dayofyear = _field_accessor(
1527+
"dayofyear",
1528+
"doy",
1529+
"""
1530+
The ordinal day of the year.
1531+
""",
1532+
)
1533+
quarter = _field_accessor(
1534+
"quarter",
1535+
"q",
1536+
"""
1537+
The quarter of the date.
1538+
""",
1539+
)
14741540
days_in_month = _field_accessor(
1475-
"days_in_month", "dim", "The number of days in the month."
1541+
"days_in_month",
1542+
"dim",
1543+
"""
1544+
The number of days in the month.
1545+
""",
14761546
)
14771547
daysinmonth = days_in_month
14781548
_is_month_doc = """

pandas/core/arrays/period.py

+71-11
Original file line numberDiff line numberDiff line change
@@ -342,25 +342,85 @@ def __array__(self, dtype=None):
342342
# --------------------------------------------------------------------
343343
# Vectorized analogues of Period properties
344344

345-
year = _field_accessor("year", 0, "The year of the period")
346-
month = _field_accessor("month", 3, "The month as January=1, December=12")
347-
day = _field_accessor("day", 4, "The days of the period")
348-
hour = _field_accessor("hour", 5, "The hour of the period")
349-
minute = _field_accessor("minute", 6, "The minute of the period")
350-
second = _field_accessor("second", 7, "The second of the period")
351-
weekofyear = _field_accessor("week", 8, "The week ordinal of the year")
345+
year = _field_accessor(
346+
"year",
347+
0,
348+
"""
349+
The year of the period.
350+
""",
351+
)
352+
month = _field_accessor(
353+
"month",
354+
3,
355+
"""
356+
The month as January=1, December=12.
357+
""",
358+
)
359+
day = _field_accessor(
360+
"day",
361+
4,
362+
"""
363+
The days of the period.
364+
""",
365+
)
366+
hour = _field_accessor(
367+
"hour",
368+
5,
369+
"""
370+
The hour of the period.
371+
""",
372+
)
373+
minute = _field_accessor(
374+
"minute",
375+
6,
376+
"""
377+
The minute of the period.
378+
""",
379+
)
380+
second = _field_accessor(
381+
"second",
382+
7,
383+
"""
384+
The second of the period.
385+
""",
386+
)
387+
weekofyear = _field_accessor(
388+
"week",
389+
8,
390+
"""
391+
The week ordinal of the year.
392+
""",
393+
)
352394
week = weekofyear
353395
dayofweek = _field_accessor(
354-
"dayofweek", 10, "The day of the week with Monday=0, Sunday=6"
396+
"dayofweek",
397+
10,
398+
"""
399+
The day of the week with Monday=0, Sunday=6.
400+
""",
355401
)
356402
weekday = dayofweek
357403
dayofyear = day_of_year = _field_accessor(
358-
"dayofyear", 9, "The ordinal day of the year"
404+
"dayofyear",
405+
9,
406+
"""
407+
The ordinal day of the year.
408+
""",
409+
)
410+
quarter = _field_accessor(
411+
"quarter",
412+
2,
413+
"""
414+
The quarter of the date.
415+
""",
359416
)
360-
quarter = _field_accessor("quarter", 2, "The quarter of the date")
361417
qyear = _field_accessor("qyear", 1)
362418
days_in_month = _field_accessor(
363-
"days_in_month", 11, "The number of days in the month"
419+
"days_in_month",
420+
11,
421+
"""
422+
The number of days in the month.
423+
""",
364424
)
365425
daysinmonth = days_in_month
366426

0 commit comments

Comments
 (0)