Skip to content

Commit d1be499

Browse files
committed
Fixing PEP8 issues
Signed-off-by: Fabian Haase <[email protected]>
1 parent 7fd215d commit d1be499

File tree

4 files changed

+26
-32
lines changed

4 files changed

+26
-32
lines changed

doc/source/advanced.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ As usual, **both sides** of the slicers are included as this is label indexing.
318318

319319
.. code-block:: python
320320
321-
df.loc[(slice('A1','A3'),.....), :]
321+
df.loc[(slice('A1', 'A3'), ...), :] # noqa: E999
322322
323323
  You should **not** do this:
324324

325325
.. code-block:: python
326326
327-
df.loc[(slice('A1','A3'),.....)]
327+
df.loc[(slice('A1', 'A3'), ...)] # noqa: E999
328328
329329
.. ipython:: python
330330
@@ -740,15 +740,13 @@ values **not** in the categories, similarly to how you can reindex **any** panda
740740

741741
.. code-block:: python
742742
743-
In [9]: df3 = pd.DataFrame({'A' : np.arange(6),
744-
'B' : pd.Series(list('aabbca')).astype('category')})
743+
>>> df3 = pd.DataFrame({'A': np.arange(6),
744+
... 'B': pd.Series(list('aabbca')).astype('category')})
745+
>>> df3 = df3.set_index('B')
746+
>>> df3.index
747+
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')
745748
746-
In [11]: df3 = df3.set_index('B')
747-
748-
In [11]: df3.index
749-
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')
750-
751-
In [12]: pd.concat([df2, df3]
749+
>>> pd.concat([df2, df3])
752750
TypeError: categories must match existing categories when appending
753751
754752
.. _indexing.rangeindex:
@@ -1033,11 +1031,11 @@ On the other hand, if the index is not monotonic, then both slice bounds must be
10331031
.. code-block:: python
10341032
10351033
# 0 is not in the index
1036-
In [9]: df.loc[0:4, :]
1034+
>>> df.loc[0:4, :]
10371035
KeyError: 0
10381036
10391037
# 3 is not a unique label
1040-
In [11]: df.loc[2:3, :]
1038+
>>> df.loc[2:3, :]
10411039
KeyError: 'Cannot get right slice bound for non-unique label: 3'
10421040
10431041
``Index.is_monotonic_increasing`` and ``Index.is_monotonic_decreasing`` only check that

doc/source/basics.rst

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -302,23 +302,17 @@ To evaluate single-element pandas objects in a boolean context, use the method
302302
303303
.. warning::
304304

305-
You might be tempted to do the following:
305+
Using a DataFrame as a condition will raise errors,
306+
as you are trying to compare multiple values:
306307

307308
.. code-block:: python
308309
309310
>>> if df:
310-
...
311-
312-
Or
313-
314-
.. code-block:: python
315-
316-
>>> df and df2
317-
318-
These will both raise errors, as you are trying to compare multiple values.
319-
320-
.. code-block:: python
311+
... do_something()
312+
ValueError: The truth value of an array is ambiguous. Use a.empty, a.any() or a.all().
321313
314+
>>> if df and df2:
315+
... do_something()
322316
ValueError: The truth value of an array is ambiguous. Use a.empty, a.any() or a.all().
323317
324318
See :ref:`gotchas<gotchas.truth>` for a more detailed discussion.
@@ -732,9 +726,8 @@ with the equivalent
732726
.. code-block:: python
733727
734728
>>> (df.pipe(h)
735-
.pipe(g, arg1=1)
736-
.pipe(f, arg2=2, arg3=3)
737-
)
729+
... .pipe(g, arg1=1)
730+
... .pipe(f, arg2=2, arg3=3))
738731
739732
Pandas encourages the second style, which is known as method chaining.
740733
``pipe`` makes it easy to use your own or another library's functions

doc/source/dsintro.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,12 @@ To write code compatible with all versions of Python, split the assignment in tw
566566
.. code-block:: python
567567
568568
>>> dependent = pd.DataFrame({"A": [1, 1, 1]})
569-
>>> dependent.assign(A=lambda x: x["A"] + 1,
570-
B=lambda x: x["A"] + 2)
569+
>>> dependent.assign(A=lambda x: x["A"] + 1, B=lambda x: x["A"] + 2)
571570
572571
For Python 3.5 and earlier the expression creating ``B`` refers to the
573572
"old" value of ``A``, ``[1, 1, 1]``. The output is then
574573

575-
.. code-block:: python
574+
.. code-block:: console
576575
577576
A B
578577
0 2 3
@@ -582,7 +581,7 @@ To write code compatible with all versions of Python, split the assignment in tw
582581
For Python 3.6 and later, the expression creating ``A`` refers to the
583582
"new" value of ``A``, ``[2, 2, 2]``, which results in
584583

585-
.. code-block:: python
584+
.. code-block:: console
586585
587586
A B
588587
0 2 4

doc/source/reshaping.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ For the curious here is how the above ``DataFrame`` was created:
4545

4646
.. code-block:: python
4747
48-
import pandas.util.testing as tm; tm.N = 3
48+
import pandas.util.testing as tm
49+
50+
tm.N = 3
51+
52+
4953
def unpivot(frame):
5054
N, K = frame.shape
5155
data = {'value': frame.values.ravel('F'),

0 commit comments

Comments
 (0)