-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
import pandas as pd
help(pd.DataFrame.swaplevel)]
# Examples section is improperly indendented:
Help on function swaplevel in module pandas.core.frame:
swaplevel(self, i: 'Axis' = -2, j: 'Axis' = -1, axis: 'Axis' = 0) -> 'DataFrame'
Swap levels i and j in a :class:`MultiIndex`.
Default is to swap the two innermost levels of the index.
Parameters
----------
i, j : int or str
Levels of the indices to be swapped. Can pass level name as string.
axis : {0 or 'index', 1 or 'columns'}, default 0
The axis to swap levels on. 0 or 'index' for row-wise, 1 or
'columns' for column-wise.
Returns
-------
DataFrame
DataFrame with levels swapped in MultiIndex.
Examples
--------
>>> df = pd.DataFrame(
... {"Grade": ["A", "B", "A", "C"]},
... index=[
... ["Final exam", "Final exam", "Coursework", "Coursework"],
... ["History", "Geography", "History", "Geography"],
... ["January", "February", "March", "April"],
... ],
... )
>>> df
...
Issue Description
Examples section is indented, starting in the middle of the header. This doesn't seem to affect docs generation (see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.swaplevel.html), but it does look odd when you view help in a Python or Ipython shell. Maybe Jupyter as well? I'm not sure.
Expected Behavior
Examples section should all be indented at the same level.
Installed Versions
pandas 1.3.4