Skip to content

Commit 1d18430

Browse files
thoojreback
authored andcommitted
Fix flake8 issues on v19, v20 and v21.0.rst (#24236)
1 parent 250dd5f commit 1d18430

File tree

4 files changed

+202
-210
lines changed

4 files changed

+202
-210
lines changed

doc/source/whatsnew/v0.19.0.rst

+66-67
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ v0.19.0 (October 2, 2016)
55

66
{{ header }}
77

8-
.. ipython:: python
9-
:suppress:
10-
11-
from pandas import * # noqa F401, F403
12-
13-
148
This is a major release from 0.18.1 and includes number of API changes, several new features,
159
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
1610
users upgrade to this version.
@@ -105,9 +99,8 @@ This also illustrates using the ``by`` parameter to group data before merging.
10599
'20160525 13:30:00.049',
106100
'20160525 13:30:00.072',
107101
'20160525 13:30:00.075']),
108-
'ticker': ['GOOG', 'MSFT', 'MSFT',
109-
'MSFT', 'GOOG', 'AAPL', 'GOOG',
110-
'MSFT'],
102+
'ticker': ['GOOG', 'MSFT', 'MSFT', 'MSFT',
103+
'GOOG', 'AAPL', 'GOOG', 'MSFT'],
111104
'bid': [720.50, 51.95, 51.97, 51.99,
112105
720.50, 97.99, 720.50, 52.01],
113106
'ask': [720.93, 51.96, 51.98, 52.00,
@@ -143,7 +136,8 @@ See the full documentation :ref:`here <stats.moments.ts>`.
143136
.. ipython:: python
144137
145138
dft = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
146-
index=pd.date_range('20130101 09:00:00', periods=5, freq='s'))
139+
index=pd.date_range('20130101 09:00:00',
140+
periods=5, freq='s'))
147141
dft
148142
149143
This is a regular frequency index. Using an integer window parameter works to roll along the window frequency.
@@ -164,13 +158,13 @@ Using a non-regular, but still monotonic index, rolling with an integer window d
164158
.. ipython:: python
165159
166160
167-
dft = DataFrame({'B': [0, 1, 2, np.nan, 4]},
168-
index = pd.Index([pd.Timestamp('20130101 09:00:00'),
169-
pd.Timestamp('20130101 09:00:02'),
170-
pd.Timestamp('20130101 09:00:03'),
171-
pd.Timestamp('20130101 09:00:05'),
172-
pd.Timestamp('20130101 09:00:06')],
173-
name='foo'))
161+
dft = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
162+
index=pd.Index([pd.Timestamp('20130101 09:00:00'),
163+
pd.Timestamp('20130101 09:00:02'),
164+
pd.Timestamp('20130101 09:00:03'),
165+
pd.Timestamp('20130101 09:00:05'),
166+
pd.Timestamp('20130101 09:00:06')],
167+
name='foo'))
174168
175169
dft
176170
dft.rolling(2).sum()
@@ -277,10 +271,10 @@ Categorical Concatenation
277271

278272
.. ipython:: python
279273
280-
from pandas.api.types import union_categoricals
281-
a = pd.Categorical(["b", "c"])
282-
b = pd.Categorical(["a", "b"])
283-
union_categoricals([a, b])
274+
from pandas.api.types import union_categoricals
275+
a = pd.Categorical(["b", "c"])
276+
b = pd.Categorical(["a", "b"])
277+
union_categoricals([a, b])
284278
285279
- ``concat`` and ``append`` now can concat ``category`` dtypes with different ``categories`` as ``object`` dtype (:issue:`13524`)
286280

@@ -289,18 +283,18 @@ Categorical Concatenation
289283
s1 = pd.Series(['a', 'b'], dtype='category')
290284
s2 = pd.Series(['b', 'c'], dtype='category')
291285
292-
**Previous behavior**:
286+
**Previous behavior**:
293287

294-
.. code-block:: ipython
288+
.. code-block:: ipython
295289
296-
In [1]: pd.concat([s1, s2])
297-
ValueError: incompatible categories in categorical concat
290+
In [1]: pd.concat([s1, s2])
291+
ValueError: incompatible categories in categorical concat
298292
299-
**New behavior**:
293+
**New behavior**:
300294

301-
.. ipython:: python
295+
.. ipython:: python
302296
303-
pd.concat([s1, s2])
297+
pd.concat([s1, s2])
304298
305299
.. _whatsnew_0190.enhancements.semi_month_offsets:
306300

@@ -313,31 +307,31 @@ These provide date offsets anchored (by default) to the 15th and end of month, a
313307

314308
.. ipython:: python
315309
316-
from pandas.tseries.offsets import SemiMonthEnd, SemiMonthBegin
310+
from pandas.tseries.offsets import SemiMonthEnd, SemiMonthBegin
317311
318312
**SemiMonthEnd**:
319313

320314
.. ipython:: python
321315
322-
Timestamp('2016-01-01') + SemiMonthEnd()
316+
pd.Timestamp('2016-01-01') + SemiMonthEnd()
323317
324-
pd.date_range('2015-01-01', freq='SM', periods=4)
318+
pd.date_range('2015-01-01', freq='SM', periods=4)
325319
326320
**SemiMonthBegin**:
327321

328322
.. ipython:: python
329323
330-
Timestamp('2016-01-01') + SemiMonthBegin()
324+
pd.Timestamp('2016-01-01') + SemiMonthBegin()
331325
332-
pd.date_range('2015-01-01', freq='SMS', periods=4)
326+
pd.date_range('2015-01-01', freq='SMS', periods=4)
333327
334328
Using the anchoring suffix, you can also specify the day of month to use instead of the 15th.
335329

336330
.. ipython:: python
337331
338-
pd.date_range('2015-01-01', freq='SMS-16', periods=4)
332+
pd.date_range('2015-01-01', freq='SMS-16', periods=4)
339333
340-
pd.date_range('2015-01-01', freq='SM-14', periods=4)
334+
pd.date_range('2015-01-01', freq='SM-14', periods=4)
341335
342336
.. _whatsnew_0190.enhancements.index:
343337

@@ -367,7 +361,7 @@ For ``MultiIndex``, values are dropped if any level is missing by default. Speci
367361
.. ipython:: python
368362
369363
midx = pd.MultiIndex.from_arrays([[1, 2, np.nan, 4],
370-
[1, 2, np.nan, np.nan]])
364+
[1, 2, np.nan, np.nan]])
371365
midx
372366
midx.dropna()
373367
midx.dropna(how='all')
@@ -377,7 +371,7 @@ For ``MultiIndex``, values are dropped if any level is missing by default. Speci
377371
.. ipython:: python
378372
379373
idx = pd.Index(["a1a2", "b1", "c1"])
380-
idx.str.extractall("[ab](?P<digit>\d)")
374+
idx.str.extractall(r"[ab](?P<digit>\d)")
381375
382376
``Index.astype()`` now accepts an optional boolean argument ``copy``, which allows optional copying if the requirements on dtype are satisfied (:issue:`13209`)
383377

@@ -453,7 +447,7 @@ The following are now part of this API:
453447
454448
import pprint
455449
from pandas.api import types
456-
funcs = [ f for f in dir(types) if not f.startswith('_') ]
450+
funcs = [f for f in dir(types) if not f.startswith('_')]
457451
pprint.pprint(funcs)
458452
459453
.. note::
@@ -470,20 +464,21 @@ Other enhancements
470464

471465
.. ipython:: python
472466
473-
pd.Timestamp(2012, 1, 1)
467+
pd.Timestamp(2012, 1, 1)
474468
475-
pd.Timestamp(year=2012, month=1, day=1, hour=8, minute=30)
469+
pd.Timestamp(year=2012, month=1, day=1, hour=8, minute=30)
476470
477471
- The ``.resample()`` function now accepts a ``on=`` or ``level=`` parameter for resampling on a datetimelike column or ``MultiIndex`` level (:issue:`13500`)
478472

479473
.. ipython:: python
480474
481475
df = pd.DataFrame({'date': pd.date_range('2015-01-01', freq='W', periods=5),
482476
'a': np.arange(5)},
483-
index=pd.MultiIndex.from_arrays([
484-
[1,2,3,4,5],
485-
pd.date_range('2015-01-01', freq='W', periods=5)],
486-
names=['v','d']))
477+
index=pd.MultiIndex.from_arrays([[1, 2, 3, 4, 5],
478+
pd.date_range('2015-01-01',
479+
freq='W',
480+
periods=5)
481+
], names=['v', 'd']))
487482
df
488483
df.resample('M', on='date').sum()
489484
df.resample('M', level='d').sum()
@@ -547,7 +542,7 @@ API changes
547542

548543
.. ipython:: python
549544
550-
s = pd.Series([1,2,3])
545+
s = pd.Series([1, 2, 3])
551546
552547
**Previous behavior**:
553548

@@ -953,7 +948,7 @@ of integers (:issue:`13988`).
953948
954949
In [6]: pi = pd.PeriodIndex(['2011-01', '2011-02'], freq='M')
955950
In [7]: pi.values
956-
array([492, 493])
951+
Out[7]: array([492, 493])
957952
958953
**New behavior**:
959954

@@ -981,23 +976,23 @@ Previous behavior:
981976

982977
.. code-block:: ipython
983978
984-
In [1]: pd.Index(['a', 'b']) + pd.Index(['a', 'c'])
985-
FutureWarning: using '+' to provide set union with Indexes is deprecated, use '|' or .union()
986-
Out[1]: Index(['a', 'b', 'c'], dtype='object')
979+
In [1]: pd.Index(['a', 'b']) + pd.Index(['a', 'c'])
980+
FutureWarning: using '+' to provide set union with Indexes is deprecated, use '|' or .union()
981+
Out[1]: Index(['a', 'b', 'c'], dtype='object')
987982
988983
**New behavior**: the same operation will now perform element-wise addition:
989984

990985
.. ipython:: python
991986
992-
pd.Index(['a', 'b']) + pd.Index(['a', 'c'])
987+
pd.Index(['a', 'b']) + pd.Index(['a', 'c'])
993988
994989
Note that numeric Index objects already performed element-wise operations.
995990
For example, the behavior of adding two integer Indexes is unchanged.
996991
The base ``Index`` is now made consistent with this behavior.
997992

998993
.. ipython:: python
999994
1000-
pd.Index([1, 2, 3]) + pd.Index([2, 3, 4])
995+
pd.Index([1, 2, 3]) + pd.Index([2, 3, 4])
1001996
1002997
Further, because of this change, it is now possible to subtract two
1003998
DatetimeIndex objects resulting in a TimedeltaIndex:
@@ -1006,15 +1001,17 @@ DatetimeIndex objects resulting in a TimedeltaIndex:
10061001

10071002
.. code-block:: ipython
10081003
1009-
In [1]: pd.DatetimeIndex(['2016-01-01', '2016-01-02']) - pd.DatetimeIndex(['2016-01-02', '2016-01-03'])
1004+
In [1]: (pd.DatetimeIndex(['2016-01-01', '2016-01-02'])
1005+
...: - pd.DatetimeIndex(['2016-01-02', '2016-01-03']))
10101006
FutureWarning: using '-' to provide set differences with datetimelike Indexes is deprecated, use .difference()
10111007
Out[1]: DatetimeIndex(['2016-01-01'], dtype='datetime64[ns]', freq=None)
10121008
10131009
**New behavior**:
10141010

10151011
.. ipython:: python
10161012
1017-
pd.DatetimeIndex(['2016-01-01', '2016-01-02']) - pd.DatetimeIndex(['2016-01-02', '2016-01-03'])
1013+
(pd.DatetimeIndex(['2016-01-01', '2016-01-02'])
1014+
- pd.DatetimeIndex(['2016-01-02', '2016-01-03']))
10181015
10191016
10201017
.. _whatsnew_0190.api.difference:
@@ -1063,7 +1060,8 @@ Previously, most ``Index`` classes returned ``np.ndarray``, and ``DatetimeIndex`
10631060
In [1]: pd.Index([1, 2, 3]).unique()
10641061
Out[1]: array([1, 2, 3])
10651062
1066-
In [2]: pd.DatetimeIndex(['2011-01-01', '2011-01-02', '2011-01-03'], tz='Asia/Tokyo').unique()
1063+
In [2]: pd.DatetimeIndex(['2011-01-01', '2011-01-02',
1064+
...: '2011-01-03'], tz='Asia/Tokyo').unique()
10671065
Out[2]:
10681066
DatetimeIndex(['2011-01-01 00:00:00+09:00', '2011-01-02 00:00:00+09:00',
10691067
'2011-01-03 00:00:00+09:00'],
@@ -1074,7 +1072,8 @@ Previously, most ``Index`` classes returned ``np.ndarray``, and ``DatetimeIndex`
10741072
.. ipython:: python
10751073
10761074
pd.Index([1, 2, 3]).unique()
1077-
pd.DatetimeIndex(['2011-01-01', '2011-01-02', '2011-01-03'], tz='Asia/Tokyo').unique()
1075+
pd.DatetimeIndex(['2011-01-01', '2011-01-02', '2011-01-03'],
1076+
tz='Asia/Tokyo').unique()
10781077
10791078
.. _whatsnew_0190.api.multiindex:
10801079

@@ -1236,29 +1235,29 @@ Operators now preserve dtypes
12361235

12371236
- Sparse data structure now can preserve ``dtype`` after arithmetic ops (:issue:`13848`)
12381237

1239-
.. ipython:: python
1238+
.. ipython:: python
12401239
1241-
s = pd.SparseSeries([0, 2, 0, 1], fill_value=0, dtype=np.int64)
1242-
s.dtype
1240+
s = pd.SparseSeries([0, 2, 0, 1], fill_value=0, dtype=np.int64)
1241+
s.dtype
12431242
1244-
s + 1
1243+
s + 1
12451244
12461245
- Sparse data structure now support ``astype`` to convert internal ``dtype`` (:issue:`13900`)
12471246

1248-
.. ipython:: python
1247+
.. ipython:: python
12491248
1250-
s = pd.SparseSeries([1., 0., 2., 0.], fill_value=0)
1251-
s
1252-
s.astype(np.int64)
1249+
s = pd.SparseSeries([1., 0., 2., 0.], fill_value=0)
1250+
s
1251+
s.astype(np.int64)
12531252
12541253
``astype`` fails if data contains values which cannot be converted to specified ``dtype``.
12551254
Note that the limitation is applied to ``fill_value`` which default is ``np.nan``.
12561255
1257-
.. code-block:: ipython
1256+
.. code-block:: ipython
12581257
1259-
In [7]: pd.SparseSeries([1., np.nan, 2., np.nan], fill_value=np.nan).astype(np.int64)
1260-
Out[7]:
1261-
ValueError: unable to coerce current fill_value nan to int64 dtype
1258+
In [7]: pd.SparseSeries([1., np.nan, 2., np.nan], fill_value=np.nan).astype(np.int64)
1259+
Out[7]:
1260+
ValueError: unable to coerce current fill_value nan to int64 dtype
12621261
12631262
Other sparse fixes
12641263
""""""""""""""""""

0 commit comments

Comments
 (0)