Repository: pandas-dev/pandas

Issue:
DOC: Make _field_accessor manage the docstring format
We started to validate the formats of docstrings. For example, we expect that the summary of the docstring starts in the next line of the opening `"""` (see #24059).

In some cases the docstrings are generated dynamically, and in the case of `_field_accessor`, we have to write some line breaks to avoid the validation to fail, for example:
```
_field_accessor('year', 'Y', "\n The year of the datetime\n")
```

In this issue we should update the code of `_field_accessor`, and modify the calls to it removing the line breaks, so the previous example becomes:
```
_field_accessor('year', 'Y', 'The year of the datetime')
```

And the docstring is composed in a way that follows our docstring standards. The standards can be checked with:
```
$ ./scripts/validate_docstrings.py --prefix=pandas.Series --errors=GL01,GL02
```
which, it should report no error (or if it reports cases that are not fixed yet, the number of errors should decrease or not increase after the change).


Discussion:
would like to fix this \n mistake i made beforehand if you don't mind... 
Not sure I understand. Your previous PR was good, it's better to fix this separate from all the other changes. And as it has already been merged, it can't be changed (if you push to your branch, nothing will be updated or happen)

Resolving patch:
diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py
--- a/pandas/core/arrays/datetimes.py
+++ b/pandas/core/arrays/datetimes.py
@@ -82,7 +82,7 @@ def f(self):
         return result
 
     f.__name__ = name
-    f.__doc__ = docstring
+    f.__doc__ = "\n{}\n".format(docstring)
     return property(f)
 
 
@@ -1129,12 +1129,12 @@ def date(self):
         "The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0")
 
     dayofyear = _field_accessor('dayofyear', 'doy',
-                                "\nThe ordinal day of the year\n")
-    quarter = _field_accessor('quarter', 'q', "\nThe quarter of the date\n")
+                                "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',
-        "\nThe number of days in the month\n")
+        "The number of days in the month.")
     daysinmonth = days_in_month
     _is_month_doc = """
         Indicates whether the date is the {first_or_last} day of the month.
diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py
--- a/pandas/core/arrays/timedeltas.py
+++ b/pandas/core/arrays/timedeltas.py
@@ -59,7 +59,7 @@ def f(self):
         return result
 
     f.__name__ = name
-    f.__doc__ = docstring
+    f.__doc__ = "\n{}\n".format(docstring)
     return property(f)
 
 
@@ -684,16 +684,16 @@ def to_pytimedelta(self):
         return tslibs.ints_to_pytimedelta(self.asi8)
 
     days = _field_accessor("days", "days",
-                           "\nNumber of days for each element.\n")
+                           "Number of days for each element.")
     seconds = _field_accessor("seconds", "seconds",
-                              "\nNumber of seconds (>= 0 and less than 1 day) "
-                              "for each element.\n")
+                              "Number of seconds (>= 0 and less than 1 day) "
+                              "for each element.")
     microseconds = _field_accessor("microseconds", "microseconds",
-                                   "\nNumber of microseconds (>= 0 and less "
-                                   "than 1 second) for each element.\n")
+                                   "Number of microseconds (>= 0 and less "
+                                   "than 1 second) for each element.")
     nanoseconds = _field_accessor("nanoseconds", "nanoseconds",
-                                  "\nNumber of nanoseconds (>= 0 and less "
-                                  "than 1 microsecond) for each element.\n")
+                                  "Number of nanoseconds (>= 0 and less "
+                                  "than 1 microsecond) for each element.")
 
     @property
     def components(self):


Test patch: