DOC: Set value for undefined variables in examples 
State: closed

- [x] closes #51342 (Replace xxxx with the GitHub issue number)
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.


Labels:
name: Docs

Comments:
There is 1 undefined error I have yet to fix, which is in line 262 of ```pandas/core/arrays/datetimelike.py```. 
![image](https://user-images.githubusercontent.com/66008784/218825138-fa3c1f16-98d1-4ecf-94e4-aa823ae03151.png). 
This method is under ```DatetimeLikeArrayMixin``` class. 

```self``` is undefined. I would like to confirm whether I should instantiate this class and replace ```self``` with the object. The class takes in in other objects, which in turn take in other objects as well, so it would involve many classes that might only make the example more confusing. 
@datapythonista Please let me know what you think!
Fantastic work, merging on green.
@[kkangs0226](https://github.com/kkangs0226) thanks a lot for your work. I wonder if you could please make the resulting html file of the docstring, and share it here as pdf? 

I think that we have to follow the documenation conventions (please see the topics regarding short names and numbers): https://pandas.pydata.org/docs/development/contributing_docstring.html#conventions-for-the-examples

We would also like to avoid extra parentheses. 

cc: @MarcoGorelli 
@DeaMariaLeon
I have updated the variable name of the dataframe to ```df``` as suggested in the documenation conventions. 
As for the extra parentheses for multi-line doctests, they are to avoid the F721 syntax error. More details can be found here: https://github.com/pandas-dev/pandas/issues/51341

I have also attached the resulting html file for your viewing.
[pandas_DataFrame_pipe.pdf](https://github.com/pandas-dev/pandas/files/10831643/pandas_DataFrame_pipe.pdf)
@kkangs0226 Thank you very much.

Yes, the parentheses are to avoid a flake8 error.  But the examples should look as if you were using the interpreter. You wouldn’t be using parentheses in that case. I opened a PR #51634  after a PR you did (it hasn't finished the ci tests). It passes flake8 locally and it doesn't have the extra parentheses. 

As for the names of the df, that's good. What I meant was also that the name of the functions are very long IMO. But if everybody is happy, that's good.

Again, thank you for all this. 


@DeaMariaLeon Thanks for the clarifications, I have removed the extra parentheses! 

As for the long function names, since they were suggested by @datapythonista , perhaps we can ask for his thoughts on it. 
The `relabel_result` doctest doesn't run. It's only an internal function, but still, having an example is useful for helping devs understand what it does. So perhaps we don't need to fix all linting errors in it, but having a running example would be good.

To get it running, I'd first look for an example of it being used in practice: for that, I went to https://pandas-coverage.herokuapp.com/ , looked for the file `pandas/core/frame.py`, and line 1980 (where `relabel_result` is used) and found that the following test hits it:
```
pandas/tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_multi_columns_multi_methods
```
I then ran that test, with a breakpoint on line 1980, and saw that the aggregations need to be part of `result`'s index

So, here's one way of writing this example such that it passes:
```python
    >>> from pandas.core.apply import relabel_result
    >>> result = pd.DataFrame(
    ...     {"A": [np.nan, 2, np.nan], "C": [6, np.nan, np.nan], "B": [np.nan, 4, 2.5]},
    ...     index=["max", "mean", "min"]
    ... )
    >>> funcs = {"A": ["max"], "C": ["max"], "B": ["mean", "min"]}
    >>> columns = ("foo", "aab", "bar", "dat")
    >>> order = [0, 1, 2, 3]
    >>> result_in_dict = relabel_result(result, funcs, columns, order)
    >>> pd.DataFrame(result_in_dict, index=columns)
           A    C    B
    foo  2.0  NaN  NaN
    aab  NaN  6.0  NaN
    bar  NaN  NaN  4.0
    dat  NaN  NaN  2.5
```
Also, for me, the `validate_docstrings` doesn't check the doctest unless I change

https://github.com/pandas-dev/pandas/blob/8a4096045c7fd9f1508e27fa93c03ce3beaaf316/pandas/core/apply.py#L1326-L1327

to

```
    Examples
    --------
```
I went ahead and fixed up the remaining tidbits, hope that's OK - thanks @kkangs0226 for your PR, and Dea for reviewing!