Skip to content

DOC: fix code-block in the reshaping docs #28838

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 10 commits into from
Oct 16, 2019
16 changes: 8 additions & 8 deletions doc/source/user_guide/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -728,14 +728,14 @@ Suppose we wanted to pivot ``df`` such that the ``col`` values are columns,
``row`` values are the index, and the mean of ``val0`` are the values? In
particular, the resulting DataFrame should look like:

.. note::

col col0 col1 col2 col3 col4
row
row0 0.77 0.605 NaN 0.860 0.65
row2 0.13 NaN 0.395 0.500 0.25
row3 NaN 0.310 NaN 0.545 NaN
row4 NaN 0.100 0.395 0.760 0.24
.. code-block:: html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be highlighted as html. I think you can probably use just :: instead for having a code block without any highlighting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Joris, when I use without highlighting checks failing on AzureDevops because flake8-rst giving E999 syntax error. You should break a 'space' after "::", but when I break a space the end of line, ci/code_checks.sh gives linting error. The AzureDevops fails again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should remove the .. code-block:: html line, and in the previous have should look like:: (see the double colon).

If that doesn't work, try .. code-block:: text or .. code-block:: none

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I will change it to .. code-block::
You will see the AzureDevops fail on flake8-rst

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the default for code-block is Python, and flake-rst is validating the content of the block assuming it's Python code, hence the syntax error.

In any case, can you implement one of the proposed options @oktaysabak please. Not so important to understand the details of the problem, let's simply fix it and get this merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes flake8-rst wants a ' ' blank after .. code-block:: like this. But if I leave a blank end of line; pandas code checker fails.( ci/code_checks.sh ) So I will change it to the .. code-block:: text than I will test it locally. I hope it will fix.


col col0 col1 col2 col3 col4
row
row0 0.77 0.605 NaN 0.860 0.65
row2 0.13 NaN 0.395 0.500 0.25
row3 NaN 0.310 NaN 0.545 NaN
row4 NaN 0.100 0.395 0.760 0.24

This solution uses :func:`~pandas.pivot_table`. Also note that
``aggfunc='mean'`` is the default. It is included here to be explicit.
Expand Down