Skip to content

Commit 7fd215d

Browse files
committed
Fixing PEP8 issues
cookbook.rst:971 -> python of .. code-block:: deleted to disable flake8-rst checks. %timeit is invalid Syntax, # noqa: E999 does not have an effect. Signed-off-by: Fabian Haase <[email protected]>
1 parent 11a3632 commit 7fd215d

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

doc/source/cookbook.rst

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -968,37 +968,34 @@ Parsing date components in multi-columns
968968

969969
Parsing date components in multi-columns is faster with a format
970970

971-
.. code-block:: python
972-
973-
In [30]: i = pd.date_range('20000101',periods=10000)
974-
975-
In [31]: df = pd.DataFrame(dict(year = i.year, month = i.month, day = i.day))
971+
.. code-block::
976972
977-
In [32]: df.head()
978-
Out[32]:
973+
>>> i = pd.date_range('20000101', periods=10000)
974+
>>> df = pd.DataFrame({year: i.year, month: i.month, day: i.day})
975+
>>> df.head()
979976
day month year
980977
0 1 1 2000
981978
1 2 1 2000
982979
2 3 1 2000
983980
3 4 1 2000
984981
4 5 1 2000
985982
986-
In [33]: %timeit pd.to_datetime(df.year*10000+df.month*100+df.day,format='%Y%m%d')
983+
>>> %timeit pd.to_datetime(df.year * 10000 + df.month * 100 + df.day,
984+
... format='%Y%m%d')
987985
100 loops, best of 3: 7.08 ms per loop
988986
989987
# simulate combinging into a string, then parsing
990-
In [34]: ds = df.apply(lambda x: "%04d%02d%02d" % (x['year'],x['month'],x['day']),axis=1)
991-
992-
In [35]: ds.head()
993-
Out[35]:
988+
>>> ds = df.apply(lambda x: "%04d%02d%02d" %
989+
... (x['year'], x['month'], x['day']), axis=1)
990+
>>> ds.head()
994991
0 20000101
995992
1 20000102
996993
2 20000103
997994
3 20000104
998995
4 20000105
999996
dtype: object
1000997
1001-
In [36]: %timeit pd.to_datetime(ds)
998+
>>> %timeit pd.to_datetime(ds)
1002999
1 loops, best of 3: 488 ms per loop
10031000
10041001
Skip row between header and data
@@ -1255,6 +1252,7 @@ The `method` argument within `DataFrame.corr` can accept a callable in addition
12551252
...
12561253
... return cov_ab / std_a / std_b
12571254
...
1255+
...
12581256
>>> df = pd.DataFrame(np.random.normal(size=(100, 3)))
12591257
...
12601258
>>> df.corr(method=distcorr)

doc/source/extending.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ your ``MyExtensionArray`` class, as follows:
157157
class MyExtensionArray(ExtensionArray, ExtensionScalarOpsMixin):
158158
pass
159159
160+
160161
MyExtensionArray._add_arithmetic_ops()
161162
MyExtensionArray._add_comparison_ops()
162163
@@ -189,6 +190,7 @@ To use a test, subclass it:
189190
190191
from pandas.tests.extension import base
191192
193+
192194
class TestConstructors(base.BaseConstructorsTests):
193195
pass
194196
@@ -261,6 +263,7 @@ Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame
261263
def _constructor_expanddim(self):
262264
return SubclassedDataFrame
263265
266+
264267
class SubclassedDataFrame(DataFrame):
265268
266269
@property
@@ -281,7 +284,7 @@ Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame
281284
>>> type(to_framed)
282285
<class '__main__.SubclassedDataFrame'>
283286
284-
>>> df = SubclassedDataFrame({'A', [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})
287+
>>> df = SubclassedDataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})
285288
>>> df
286289
A B C
287290
0 1 4 7
@@ -297,6 +300,7 @@ Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame
297300
0 1 4
298301
1 2 5
299302
2 3 6
303+
300304
>>> type(sliced1)
301305
<class '__main__.SubclassedDataFrame'>
302306
@@ -306,6 +310,7 @@ Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame
306310
1 2
307311
2 3
308312
Name: A, dtype: int64
313+
309314
>>> type(sliced2)
310315
<class '__main__.SubclassedSeries'>
311316

doc/source/indexing.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,10 @@ A list of indexers where any element is out of bounds will raise an
537537

538538
.. code-block:: python
539539
540-
dfl.iloc[[4, 5, 6]]
540+
>>> dfl.iloc[[4, 5, 6]]
541541
IndexError: positional indexers are out-of-bounds
542542
543-
dfl.iloc[:, 4]
543+
>>> dfl.iloc[:, 4]
544544
IndexError: single positional indexer is out-of-bounds
545545
546546
.. _indexing.callable:
@@ -1794,7 +1794,7 @@ interpreter executes this code:
17941794

17951795
.. code-block:: python
17961796
1797-
dfmi.loc[:,('one','second')] = value
1797+
dfmi.loc[:, ('one', 'second')] = value
17981798
# becomes
17991799
dfmi.loc.__setitem__((slice(None), ('one', 'second')), value)
18001800
@@ -1827,10 +1827,10 @@ that you've done this:
18271827
.. code-block:: python
18281828
18291829
def do_something(df):
1830-
foo = df[['bar', 'baz']] # Is foo a view? A copy? Nobody knows!
1831-
# ... many lines here ...
1832-
foo['quux'] = value # We don't know whether this will modify df or not!
1833-
return foo
1830+
foo = df[['bar', 'baz']] # Is foo a view? A copy? Nobody knows!
1831+
# ... many lines here ...
1832+
foo['quux'] = value # We don't know whether this will modify df or not!
1833+
return foo
18341834
18351835
Yikes!
18361836

doc/source/missing_data.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,8 @@ You can also operate on the DataFrame in place:
696696

697697
.. code-block:: python
698698
699-
s = pd.Series([True, False, True])
700-
s.replace({'a string': 'new value', True: False}) # raises
701-
699+
>>> s = pd.Series([True, False, True])
700+
>>> s.replace({'a string': 'new value', True: False}) # raises
702701
TypeError: Cannot compare types 'ndarray(dtype=bool)' and 'str'
703702
704703
will raise a ``TypeError`` because one of the ``dict`` keys is not of the

0 commit comments

Comments
 (0)