DOC: fix rendering of example function in cookbook
Fix #23128 
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23153?src=pr&el=h1) Report
> Merging [#23153](https://codecov.io/gh/pandas-dev/pandas/pull/23153?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2f05cc8580ef1be09c88d32f5924b7762b619729?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/23153/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23153?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #23153   +/-   ##
=======================================
  Coverage   92.13%   92.13%           
=======================================
  Files         170      170           
  Lines       51078    51078           
=======================================
  Hits        47061    47061           
  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/23153?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/23153?src=pr&el=footer). Last update [2f05cc8...14064e1](https://codecov.io/gh/pandas-dev/pandas/pull/23153?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 Merging, this it is annoying that the docs currently don't build.

@thoo Thanks! @jorisvandenbossche  Thanks. Glad to be part of it!!!