Skip to content

DOC: Fix swaplevel docstring #44740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2021

Conversation

TheNeuralBit
Copy link
Contributor

@TheNeuralBit TheNeuralBit commented Dec 3, 2021

@TheNeuralBit TheNeuralBit changed the title Fix swaplevel docstring DOC: Fix swaplevel docstring Dec 3, 2021
@TheNeuralBit
Copy link
Contributor Author

If possible (and if there's going to be a 1.3.5) I'd like to make this change on the 1.3 branch as well. Is there a process for that?

@phofl
Copy link
Member

phofl commented Dec 4, 2021

In general we do not backport doc fixes if they were not introduced on the release before

@jreback jreback added the Docs label Dec 4, 2021
@jreback jreback added this to the 1.4 milestone Dec 4, 2021
@jreback
Copy link
Contributor

jreback commented Dec 4, 2021

hmm something odd with the validation here, can you see if you can address this: https://github.com/pandas-dev/pandas/runs/4413823661?check_suite_focus=true

@jreback
Copy link
Contributor

jreback commented Dec 7, 2021

and this renders ok?

@TheNeuralBit
Copy link
Contributor Author

Check failure https://github.com/pandas-dev/pandas/runs/4436214474?check_suite_focus=true looks like a flake. Could someone re-run?

@TheNeuralBit
Copy link
Contributor Author

and this renders ok?

pd.Series.swaplevel:

Signature: pd.Series.swaplevel(self, i=-2, j=-1, copy=True) -> 'Series'
Docstring:
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.
copy : bool, default True
            Whether to copy underlying data.

Returns
-------
Series
    Series with levels swapped in MultiIndex.

Examples
--------
>>> s = pd.Series(
...     ["A", "B", "A", "C"],
...     index=[
...         ["Final exam", "Final exam", "Coursework", "Coursework"],
...         ["History", "Geography", "History", "Geography"],
...         ["January", "February", "March", "April"],
...     ],
... )
>>> s
Final exam  History     January      A
            Geography   February     B
Coursework  History     March        A
            Geography   April        C
dtype: object

...

pd.DataFrame.swaplevel?:

Signature:
pd.DataFrame.swaplevel(
    self,
    i: 'Axis' = -2,
    j: 'Axis' = -1,
    axis: 'Axis' = 0,
) -> 'DataFrame'
Docstring:
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"],
...     ],
... )

...

Series.swaplevel API Reference:
image

DataFrame.swaplevel API Reference: image

@TheNeuralBit
Copy link
Contributor Author

In general we do not backport doc fixes if they were not introduced on the release before

Sorry I'm not quite sure what you mean by this, the Examples section was introduced in the previous minor release (1.3.0). Do you mean this could only be backported to 1.3 if the doc regression was introduced in 1.2?

I'm not trying to push back too hard on this, I'll respect whatever you want to do here. Just trying to understand the policy

@jreback
Copy link
Contributor

jreback commented Dec 8, 2021

In general we do not backport doc fixes if they were not introduced on the release before

Sorry I'm not quite sure what you mean by this, the Examples section was introduced in the previous minor release (1.3.0). Do you mean this could only be backported to 1.3 if the doc regression was introduced in 1.2?

I'm not trying to push back too hard on this, I'll respect whatever you want to do here. Just trying to understand the policy

we only backport code change regressions, and 1.3.x is at an end.

@jreback jreback merged commit a3702e2 into pandas-dev:master Dec 8, 2021
@jreback
Copy link
Contributor

jreback commented Dec 8, 2021

thanks @TheNeuralBit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: swaplevel docstring incorrectly indented at Examples
3 participants