Skip to content

Integrate flake8_rst into ./ci/code_check.sh #23381

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 16 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixing PEP8 issues
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
  • Loading branch information
FHaase committed Oct 27, 2018
commit d1be499e2d4d278b1733420205ec51a8bfc3b89b
22 changes: 10 additions & 12 deletions doc/source/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ As usual, **both sides** of the slicers are included as this is label indexing.

.. code-block:: python

df.loc[(slice('A1','A3'),.....), :]
df.loc[(slice('A1', 'A3'), ...), :] # noqa: E999

  You should **not** do this:

.. code-block:: python

df.loc[(slice('A1','A3'),.....)]
df.loc[(slice('A1', 'A3'), ...)] # noqa: E999

.. ipython:: python

Expand Down Expand Up @@ -740,15 +740,13 @@ values **not** in the categories, similarly to how you can reindex **any** panda

.. code-block:: python

In [9]: df3 = pd.DataFrame({'A' : np.arange(6),
'B' : pd.Series(list('aabbca')).astype('category')})
>>> df3 = pd.DataFrame({'A': np.arange(6),
... 'B': pd.Series(list('aabbca')).astype('category')})
>>> df3 = df3.set_index('B')
>>> df3.index
CategoricalIndex([u'a', u'a', u'b', u'b', u'c', u'a'], categories=[u'a', u'b', u'c'], ordered=False, name=u'B', dtype='category')

In [11]: df3 = df3.set_index('B')

In [11]: df3.index
Out[11]: CategoricalIndex([u'a', u'a', u'b', u'b', u'c', u'a'], categories=[u'a', u'b', u'c'], ordered=False, name=u'B', dtype='category')

In [12]: pd.concat([df2, df3]
>>> pd.concat([df2, df3])
TypeError: categories must match existing categories when appending

.. _indexing.rangeindex:
Expand Down Expand Up @@ -1033,11 +1031,11 @@ On the other hand, if the index is not monotonic, then both slice bounds must be
.. code-block:: python

# 0 is not in the index
In [9]: df.loc[0:4, :]
>>> df.loc[0:4, :]
KeyError: 0

# 3 is not a unique label
In [11]: df.loc[2:3, :]
>>> df.loc[2:3, :]
KeyError: 'Cannot get right slice bound for non-unique label: 3'

``Index.is_monotonic_increasing`` and ``Index.is_monotonic_decreasing`` only check that
Expand Down
23 changes: 8 additions & 15 deletions doc/source/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,17 @@ To evaluate single-element pandas objects in a boolean context, use the method

.. warning::

You might be tempted to do the following:
Using a DataFrame as a condition will raise errors,
Copy link
Member

Choose a reason for hiding this comment

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

What was the point of changing this? We always ask changes to have one focus to keep diff minimal. Would prefer if you could back out anything unrelated to the flake8 and do in a separate PR

as you are trying to compare multiple values:

.. code-block:: python

>>> if df:
...

Or

.. code-block:: python

>>> df and df2

These will both raise errors, as you are trying to compare multiple values.

.. code-block:: python
... do_something()
ValueError: The truth value of an array is ambiguous. Use a.empty, a.any() or a.all().

>>> if df and df2:
... do_something()
ValueError: The truth value of an array is ambiguous. Use a.empty, a.any() or a.all().

See :ref:`gotchas<gotchas.truth>` for a more detailed discussion.
Expand Down Expand Up @@ -732,9 +726,8 @@ with the equivalent
.. code-block:: python

>>> (df.pipe(h)
.pipe(g, arg1=1)
.pipe(f, arg2=2, arg3=3)
)
... .pipe(g, arg1=1)
... .pipe(f, arg2=2, arg3=3))

Pandas encourages the second style, which is known as method chaining.
``pipe`` makes it easy to use your own or another library's functions
Expand Down
7 changes: 3 additions & 4 deletions doc/source/dsintro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,12 @@ To write code compatible with all versions of Python, split the assignment in tw
.. code-block:: python

>>> dependent = pd.DataFrame({"A": [1, 1, 1]})
>>> dependent.assign(A=lambda x: x["A"] + 1,
B=lambda x: x["A"] + 2)
>>> dependent.assign(A=lambda x: x["A"] + 1, B=lambda x: x["A"] + 2)

For Python 3.5 and earlier the expression creating ``B`` refers to the
"old" value of ``A``, ``[1, 1, 1]``. The output is then

.. code-block:: python
.. code-block:: console

A B
0 2 3
Expand All @@ -582,7 +581,7 @@ To write code compatible with all versions of Python, split the assignment in tw
For Python 3.6 and later, the expression creating ``A`` refers to the
"new" value of ``A``, ``[2, 2, 2]``, which results in

.. code-block:: python
.. code-block:: console

A B
0 2 4
Expand Down
6 changes: 5 additions & 1 deletion doc/source/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ For the curious here is how the above ``DataFrame`` was created:

.. code-block:: python

import pandas.util.testing as tm; tm.N = 3
import pandas.util.testing as tm

tm.N = 3


def unpivot(frame):
N, K = frame.shape
data = {'value': frame.values.ravel('F'),
Expand Down