Remove blank lines-->fix cookbook rendering issue
State: closed

Fixes #23128 


Labels:

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23144?src=pr&el=h1) Report
> Merging [#23144](https://codecov.io/gh/pandas-dev/pandas/pull/23144?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/85dc1713bc6a1064f4afdf2a907bc9c72cdc364b?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/23144/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23144?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #23144   +/-   ##
=======================================
  Coverage   92.13%   92.13%           
=======================================
  Files         170      170           
  Lines       51073    51073           
=======================================
  Hits        47056    47056           
  Misses       4017     4017
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.56% <ø> (ø)` | :arrow_up: |
| #single | `42.28% <ø> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23144?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23144?src=pr&el=footer). Last update [85dc171...7e6864d](https://codecov.io/gh/pandas-dev/pandas/pull/23144?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

what are you removing lines? if anything they improve code readability
@jreback Yes I was removing lines. Ipython directive has a bug to cut off a function block if there is a blank line. Please let me know if there is another way to do it. 
 better way is to use multiple ipython blocks (caveat is that they cannot span a single function definition)
simpler and more descriptive (as u. can comment on code)
having large blocks of code is an anti-pattern
But can we split the code of a function across different ipython blocks?

I'm thinking that may be a better option is to use a `python` code block instead of an `ipython` one. That should fix the problem and we still keep the readability of the code.

Closing this PR. @thoo do you want to take care of that? The idea is to use  `.. code-block:: python` instead. And that requires that instead of the code directly without the outputs, we use `>>>` and the outputs, for example:
```
>>> def func():
...      print('hello world')
>>> func()
hello world
```
@datapythonista Sure. Let me take a look. Hopefully it is straight forward. 
@datapythonista  Will this work?
```
>>> def distcorr(x, y):
...     n = len(x)
...     a = np.zeros(shape=(n, n))
...     b = np.zeros(shape=(n, n))

...     for i in range(n):
...         for j in range(i + 1, n):
...             a[i, j] = abs(x[i] - x[j])
...             b[i, j] = abs(y[i] - y[j])
...     a += a.T
...     b += b.T

...     a_bar = np.vstack([np.nanmean(a, axis=0)] * n)
...     b_bar = np.vstack([np.nanmean(b, axis=0)] * n)

...     A = a - a_bar - a_bar.T + np.full(shape=(n, n), fill_value=a_bar.mean())
...     B = b - b_bar - b_bar.T + np.full(shape=(n, n), fill_value=b_bar.mean())

...     cov_ab = np.sqrt(np.nansum(A * B)) / n
...     std_a = np.sqrt(np.sqrt(np.nansum(A**2)) / n)
...     std_b = np.sqrt(np.sqrt(np.nansum(B**2)) / n)

...     return cov_ab / std_a / std_b

>>> df = pd.DataFrame(np.random.normal(size=(100, 3)))

>>> df.corr(method=distcorr)
       0         1         2
0  1.000000  0.209812  0.132786
1  0.209812  1.000000  0.153526
2  0.132786  0.153526  1.000000
```
I think you need the `...` in the blank lines too. Can you check how to run doctests on the Internet, and find a way to run it to make sure please.