Skip to content

Commit 42cf721

Browse files
JimJeonPingviinituutti
authored andcommitted
DOC: Fix flake8 issues with whatsnew v0.18.* (pandas-dev#24303)
1 parent f19dd9e commit 42cf721

File tree

3 files changed

+47
-50
lines changed

3 files changed

+47
-50
lines changed

doc/source/whatsnew/v0.18.0.rst

+19-23
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ v0.18.0 (March 13, 2016)
55

66
{{ header }}
77

8-
.. ipython:: python
9-
:suppress:
10-
11-
from pandas import * # noqa F401, F403
12-
138

149
This is a major release from 0.17.1 and includes a small number of API changes, several new features,
1510
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
@@ -64,14 +59,14 @@ Window functions have been refactored to be methods on ``Series/DataFrame`` obje
6459
.. ipython:: python
6560
6661
np.random.seed(1234)
67-
df = pd.DataFrame({'A' : range(10), 'B' : np.random.randn(10)})
62+
df = pd.DataFrame({'A': range(10), 'B': np.random.randn(10)})
6863
df
6964
7065
Previous Behavior:
7166

7267
.. code-block:: ipython
7368
74-
In [8]: pd.rolling_mean(df,window=3)
69+
In [8]: pd.rolling_mean(df, window=3)
7570
FutureWarning: pd.rolling_mean is deprecated for DataFrame and will be removed in a future version, replace with
7671
DataFrame.rolling(window=3,center=False).mean()
7772
Out[8]:
@@ -102,7 +97,7 @@ with tab-completion of available methods and properties.
10297

10398
.. code-block:: ipython
10499
105-
In [9]: r.
100+
In [9]: r.<TAB> # noqa E225, E999
106101
r.A r.agg r.apply r.count r.exclusions r.max r.median r.name r.skew r.sum
107102
r.B r.aggregate r.corr r.cov r.kurt r.mean r.min r.quantile r.std r.var
108103
@@ -122,8 +117,8 @@ And multiple aggregations
122117

123118
.. ipython:: python
124119
125-
r.agg({'A' : ['mean','std'],
126-
'B' : ['mean','std']})
120+
r.agg({'A': ['mean', 'std'],
121+
'B': ['mean', 'std']})
127122
128123
.. _whatsnew_0180.enhancements.rename:
129124

@@ -201,7 +196,7 @@ Currently the default is ``expand=None`` which gives a ``FutureWarning`` and use
201196

202197
.. code-block:: ipython
203198
204-
In [1]: pd.Series(['a1', 'b2', 'c3']).str.extract('[ab](\d)', expand=None)
199+
In [1]: pd.Series(['a1', 'b2', 'c3']).str.extract(r'[ab](\d)', expand=None)
205200
FutureWarning: currently extract(expand=None) means expand=False (return Index/Series/DataFrame)
206201
but in a future version of pandas this will be changed to expand=True (return DataFrame)
207202
@@ -216,13 +211,13 @@ Extracting a regular expression with one group returns a Series if
216211

217212
.. ipython:: python
218213
219-
pd.Series(['a1', 'b2', 'c3']).str.extract('[ab](\d)', expand=False)
214+
pd.Series(['a1', 'b2', 'c3']).str.extract(r'[ab](\d)', expand=False)
220215
221216
It returns a ``DataFrame`` with one column if ``expand=True``.
222217

223218
.. ipython:: python
224219
225-
pd.Series(['a1', 'b2', 'c3']).str.extract('[ab](\d)', expand=True)
220+
pd.Series(['a1', 'b2', 'c3']).str.extract(r'[ab](\d)', expand=True)
226221
227222
Calling on an ``Index`` with a regex with exactly one capture group
228223
returns an ``Index`` if ``expand=False``.
@@ -270,13 +265,13 @@ match.
270265
271266
s = pd.Series(["a1a2", "b1", "c1"], ["A", "B", "C"])
272267
s
273-
s.str.extract("(?P<letter>[ab])(?P<digit>\d)", expand=False)
268+
s.str.extract(r"(?P<letter>[ab])(?P<digit>\d)", expand=False)
274269
275270
The ``extractall`` method returns all matches.
276271

277272
.. ipython:: python
278273
279-
s.str.extractall("(?P<letter>[ab])(?P<digit>\d)")
274+
s.str.extractall(r"(?P<letter>[ab])(?P<digit>\d)")
280275
281276
.. _whatsnew_0180.enhancements.strcat:
282277

@@ -289,12 +284,12 @@ A new, friendlier ``ValueError`` is added to protect against the mistake of supp
289284

290285
.. ipython:: python
291286
292-
pd.Series(['a','b',np.nan,'c']).str.cat(sep=' ')
293-
pd.Series(['a','b',np.nan,'c']).str.cat(sep=' ', na_rep='?')
287+
pd.Series(['a', 'b', np.nan, 'c']).str.cat(sep=' ')
288+
pd.Series(['a', 'b', np.nan, 'c']).str.cat(sep=' ', na_rep='?')
294289
295290
.. code-block:: ipython
296291
297-
In [2]: pd.Series(['a','b',np.nan,'c']).str.cat(' ')
292+
In [2]: pd.Series(['a', 'b', np.nan, 'c']).str.cat(' ')
298293
ValueError: Did you mean to supply a `sep` keyword?
299294
300295
@@ -329,7 +324,7 @@ Timedeltas
329324

330325
.. ipython:: python
331326
332-
t = timedelta_range('1 days 2 hr 13 min 45 us',periods=3,freq='d')
327+
t = timedelta_range('1 days 2 hr 13 min 45 us', periods=3, freq='d')
333328
t
334329
t.round('10min')
335330
@@ -356,7 +351,7 @@ Previous Behavior:
356351

357352
.. code-block:: ipython
358353
359-
In [2]: s = pd.Series([1,2,3], index=np.arange(3.))
354+
In [2]: s = pd.Series([1, 2, 3], index=np.arange(3.))
360355
361356
In [3]: s
362357
Out[3]:
@@ -378,7 +373,7 @@ New Behavior:
378373

379374
.. ipython:: python
380375
381-
s = pd.Series([1,2,3], index=np.arange(3.))
376+
s = pd.Series([1, 2, 3], index=np.arange(3.))
382377
s
383378
s.index
384379
print(s.to_csv(path_or_buf=None, header=False))
@@ -727,7 +722,8 @@ Like the change in the window functions API :ref:`above <whatsnew_0180.enhanceme
727722
np.random.seed(1234)
728723
df = pd.DataFrame(np.random.rand(10,4),
729724
columns=list('ABCD'),
730-
index=pd.date_range('2010-01-01 09:00:00', periods=10, freq='s'))
725+
index=pd.date_range('2010-01-01 09:00:00',
726+
periods=10, freq='s'))
731727
df
732728
733729
@@ -1137,7 +1133,7 @@ and setting
11371133
11381134
Positional setting with ``.ix`` and a float indexer will ADD this value to the index, rather than previously setting the value by position.
11391135

1140-
.. code-block:: python
1136+
.. code-block:: ipython
11411137
11421138
In [3]: s2.ix[1.0] = 10
11431139
In [4]: s2

doc/source/whatsnew/v0.18.1.rst

+28-25
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ v0.18.1 (May 3, 2016)
55

66
{{ header }}
77

8-
.. ipython:: python
9-
:suppress:
10-
11-
from pandas import * # noqa F401, F403
12-
138

149
This is a minor bug-fix release from 0.18.0 and includes a large number of
1510
bug fixes along with several new features, enhancements, and performance improvements.
@@ -53,7 +48,8 @@ Friday before MLK Day
5348

5449
.. ipython:: python
5550
56-
dt = datetime(2014, 1, 17, 15)
51+
import datetime
52+
dt = datetime.datetime(2014, 1, 17, 15)
5753
5854
dt + bhour_us
5955
@@ -171,8 +167,7 @@ without using temporary variable.
171167
bb = pd.read_csv('data/baseball.csv', index_col='id')
172168
(bb.groupby(['year', 'team'])
173169
.sum()
174-
.loc[lambda df: df.r > 100]
175-
)
170+
.loc[lambda df: df.r > 100])
176171
177172
.. _whatsnew_0181.partial_string_indexing:
178173

@@ -183,12 +178,13 @@ Partial string indexing now matches on ``DateTimeIndex`` when part of a ``MultiI
183178

184179
.. ipython:: python
185180
186-
dft2 = pd.DataFrame(np.random.randn(20, 1),
187-
columns=['A'],
188-
index=pd.MultiIndex.from_product([pd.date_range('20130101',
189-
periods=10,
190-
freq='12H'),
191-
['a', 'b']]))
181+
dft2 = pd.DataFrame(
182+
np.random.randn(20, 1),
183+
columns=['A'],
184+
index=pd.MultiIndex.from_product([pd.date_range('20130101',
185+
periods=10,
186+
freq='12H'),
187+
['a', 'b']]))
192188
dft2
193189
dft2.loc['2013-01-05']
194190
@@ -317,8 +313,8 @@ The index in ``.groupby(..).nth()`` output is now more consistent when the ``as_
317313

318314
.. ipython:: python
319315
320-
df = DataFrame({'A' : ['a', 'b', 'a'],
321-
'B' : [1, 2, 3]})
316+
df = pd.DataFrame({'A': ['a', 'b', 'a'],
317+
'B': [1, 2, 3]})
322318
df
323319
324320
Previous Behavior:
@@ -433,13 +429,15 @@ Previous behavior:
433429

434430
.. code-block:: ipython
435431
436-
In [1]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x.value.sum())
432+
In [1]: df.groupby(pd.TimeGrouper(key='date',
433+
...: freq='M')).apply(lambda x: x.value.sum())
437434
Out[1]:
438435
...
439436
TypeError: cannot concatenate a non-NDFrame object
440437
441438
# Output is a Series
442-
In [2]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x[['value']].sum())
439+
In [2]: df.groupby(pd.TimeGrouper(key='date',
440+
...: freq='M')).apply(lambda x: x[['value']].sum())
443441
Out[2]:
444442
date
445443
2000-10-31 value 10
@@ -448,18 +446,20 @@ Previous behavior:
448446
449447
New Behavior:
450448

451-
.. code-block:: python
449+
.. code-block:: ipython
452450
453451
# Output is a Series
454-
In [55]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x.value.sum())
452+
In [55]: df.groupby(pd.TimeGrouper(key='date',
453+
...: freq='M')).apply(lambda x: x.value.sum())
455454
Out[55]:
456455
date
457456
2000-10-31 10
458457
2000-11-30 13
459458
Freq: M, dtype: int64
460459
461460
# Output is a DataFrame
462-
In [56]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x[['value']].sum())
461+
In [56]: df.groupby(pd.TimeGrouper(key='date',
462+
...: freq='M')).apply(lambda x: x[['value']].sum())
463463
Out[56]:
464464
value
465465
date
@@ -471,30 +471,33 @@ New Behavior:
471471
Changes in ``read_csv`` exceptions
472472
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
473473

474+
474475
In order to standardize the ``read_csv`` API for both the ``c`` and ``python`` engines, both will now raise an
475476
``EmptyDataError``, a subclass of ``ValueError``, in response to empty columns or header (:issue:`12493`, :issue:`12506`)
476477

477478
Previous behaviour:
478479

479480
.. code-block:: ipython
480481
481-
In [1]: df = pd.read_csv(StringIO(''), engine='c')
482+
In [1]: import io
483+
484+
In [2]: df = pd.read_csv(io.StringIO(''), engine='c')
482485
...
483486
ValueError: No columns to parse from file
484487
485-
In [2]: df = pd.read_csv(StringIO(''), engine='python')
488+
In [3]: df = pd.read_csv(io.StringIO(''), engine='python')
486489
...
487490
StopIteration
488491
489492
New behaviour:
490493

491494
.. code-block:: ipython
492495
493-
In [1]: df = pd.read_csv(StringIO(''), engine='c')
496+
In [1]: df = pd.read_csv(io.StringIO(''), engine='c')
494497
...
495498
pandas.io.common.EmptyDataError: No columns to parse from file
496499
497-
In [2]: df = pd.read_csv(StringIO(''), engine='python')
500+
In [2]: df = pd.read_csv(io.StringIO(''), engine='python')
498501
...
499502
pandas.io.common.EmptyDataError: No columns to parse from file
500503

setup.cfg

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ exclude =
5555
doc/source/whatsnew/v0.16.2.rst
5656
doc/source/whatsnew/v0.17.0.rst
5757
doc/source/whatsnew/v0.17.1.rst
58-
doc/source/whatsnew/v0.18.0.rst
59-
doc/source/whatsnew/v0.18.1.rst
6058
doc/source/basics.rst
6159
doc/source/contributing_docstring.rst
6260
doc/source/enhancingperf.rst

0 commit comments

Comments
 (0)