Skip to content

Commit f146c55

Browse files
saurav-chakravortyTomAugspurger
authored andcommitted
DOC: Fix flake 8 errors for whatsnew v0.16* (pandas-dev#24338)
1 parent e733af6 commit f146c55

File tree

4 files changed

+73
-84
lines changed

4 files changed

+73
-84
lines changed

doc/source/whatsnew/v0.16.0.rst

+32-35
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ v0.16.0 (March 22, 2015)
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.15.2 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
@@ -58,7 +53,7 @@ and the entire DataFrame (with all original and new columns) is returned.
5853

5954
.. ipython :: python
6055
61-
iris = read_csv('data/iris.data')
56+
iris = pd.read_csv('data/iris.data')
6257
iris.head()
6358
6459
iris.assign(sepal_ratio=iris['SepalWidth'] / iris['SepalLength']).head()
@@ -77,9 +72,10 @@ calculate the ratio, and plot
7772

7873
.. ipython:: python
7974
75+
iris = pd.read_csv('data/iris.data')
8076
(iris.query('SepalLength > 5')
81-
.assign(SepalRatio = lambda x: x.SepalWidth / x.SepalLength,
82-
PetalRatio = lambda x: x.PetalWidth / x.PetalLength)
77+
.assign(SepalRatio=lambda x: x.SepalWidth / x.SepalLength,
78+
PetalRatio=lambda x: x.PetalWidth / x.PetalLength)
8379
.plot(kind='scatter', x='SepalRatio', y='PetalRatio'))
8480
8581
.. image:: ../_static/whatsnew_assign.png
@@ -97,15 +93,14 @@ Added :meth:`SparseSeries.to_coo` and :meth:`SparseSeries.from_coo` methods (:is
9793

9894
.. ipython:: python
9995
100-
from numpy import nan
101-
s = Series([3.0, nan, 1.0, 3.0, nan, nan])
102-
s.index = MultiIndex.from_tuples([(1, 2, 'a', 0),
103-
(1, 2, 'a', 1),
104-
(1, 1, 'b', 0),
105-
(1, 1, 'b', 1),
106-
(2, 1, 'b', 0),
107-
(2, 1, 'b', 1)],
108-
names=['A', 'B', 'C', 'D'])
96+
s = pd.Series([3.0, np.nan, 1.0, 3.0, np.nan, np.nan])
97+
s.index = pd.MultiIndex.from_tuples([(1, 2, 'a', 0),
98+
(1, 2, 'a', 1),
99+
(1, 1, 'b', 0),
100+
(1, 1, 'b', 1),
101+
(2, 1, 'b', 0),
102+
(2, 1, 'b', 1)],
103+
names=['A', 'B', 'C', 'D'])
109104
110105
s
111106
@@ -129,11 +124,11 @@ from a ``scipy.sparse.coo_matrix``:
129124
130125
from scipy import sparse
131126
A = sparse.coo_matrix(([3.0, 1.0, 2.0], ([1, 0, 0], [0, 2, 3])),
132-
shape=(3, 4))
127+
shape=(3, 4))
133128
A
134129
A.todense()
135130
136-
ss = SparseSeries.from_coo(A)
131+
ss = pd.SparseSeries.from_coo(A)
137132
ss
138133
139134
.. _whatsnew_0160.enhancements.string:
@@ -153,22 +148,22 @@ String Methods Enhancements
153148

154149
.. ipython:: python
155150
156-
s = Series(['abcd', '3456', 'EFGH'])
151+
s = pd.Series(['abcd', '3456', 'EFGH'])
157152
s.str.isalpha()
158153
s.str.find('ab')
159154
160155
- :meth:`Series.str.pad` and :meth:`Series.str.center` now accept ``fillchar`` option to specify filling character (:issue:`9352`)
161156

162157
.. ipython:: python
163158
164-
s = Series(['12', '300', '25'])
159+
s = pd.Series(['12', '300', '25'])
165160
s.str.pad(5, fillchar='_')
166161
167162
- Added :meth:`Series.str.slice_replace`, which previously raised ``NotImplementedError`` (:issue:`8888`)
168163

169164
.. ipython:: python
170165
171-
s = Series(['ABCD', 'EFGH', 'IJK'])
166+
s = pd.Series(['ABCD', 'EFGH', 'IJK'])
172167
s.str.slice_replace(1, 3, 'X')
173168
# replaced with empty char
174169
s.str.slice_replace(0, 1)
@@ -192,7 +187,7 @@ Other enhancements
192187
.. code-block:: python
193188
194189
# Returns the 1st and 4th sheet, as a dictionary of DataFrames.
195-
pd.read_excel('path_to_file.xls',sheetname=['Sheet1',3])
190+
pd.read_excel('path_to_file.xls', sheetname=['Sheet1', 3])
196191
197192
198193
- Allow Stata files to be read incrementally with an iterator; support for long strings in Stata files. See the docs :ref:`here<io.stata_reader>` (:issue:`9493`:).
@@ -273,11 +268,11 @@ The behavior of a small sub-set of edge cases for using ``.loc`` have changed (:
273268

274269
.. ipython:: python
275270
276-
df = DataFrame(np.random.randn(5,4),
277-
columns=list('ABCD'),
278-
index=date_range('20130101',periods=5))
271+
df = pd.DataFrame(np.random.randn(5, 4),
272+
columns=list('ABCD'),
273+
index=pd.date_range('20130101', periods=5))
279274
df
280-
s = Series(range(5),[-2,-1,1,2,3])
275+
s = pd.Series(range(5), [-2, -1, 1, 2, 3])
281276
s
282277
283278
Previous Behavior
@@ -347,7 +342,7 @@ Previous Behavior
347342

348343
.. code-block:: ipython
349344
350-
In [3]: s = Series([0,1,2], dtype='category')
345+
In [3]: s = pd.Series([0, 1, 2], dtype='category')
351346
352347
In [4]: s
353348
Out[4]:
@@ -374,23 +369,23 @@ New Behavior
374369

375370
.. ipython:: python
376371
377-
s = Series([0,1,2], dtype='category')
372+
s = pd.Series([0, 1, 2], dtype='category')
378373
s
379374
s.cat.ordered
380375
s = s.cat.as_ordered()
381376
s
382377
s.cat.ordered
383378
384379
# you can set in the constructor of the Categorical
385-
s = Series(Categorical([0,1,2],ordered=True))
380+
s = pd.Series(pd.Categorical([0, 1, 2], ordered=True))
386381
s
387382
s.cat.ordered
388383
389384
For ease of creation of series of categorical data, we have added the ability to pass keywords when calling ``.astype()``. These are passed directly to the constructor.
390385

391386
.. code-block:: python
392387
393-
In [54]: s = Series(["a","b","c","a"]).astype('category',ordered=True)
388+
In [54]: s = pd.Series(["a", "b", "c", "a"]).astype('category', ordered=True)
394389
395390
In [55]: s
396391
Out[55]:
@@ -401,7 +396,8 @@ For ease of creation of series of categorical data, we have added the ability to
401396
dtype: category
402397
Categories (3, object): [a < b < c]
403398
404-
In [56]: s = Series(["a","b","c","a"]).astype('category',categories=list('abcdef'),ordered=False)
399+
In [56]: s = (pd.Series(["a", "b", "c", "a"])
400+
....: .astype('category', categories=list('abcdef'), ordered=False))
405401
406402
In [57]: s
407403
Out[57]:
@@ -449,7 +445,7 @@ Other API Changes
449445

450446
.. code-block:: ipython
451447
452-
In [2]: pd.Series([0,1,2,3], list('abcd')) | pd.Series([4,4,4,4], list('abcd'))
448+
In [2]: pd.Series([0, 1, 2, 3], list('abcd')) | pd.Series([4, 4, 4, 4], list('abcd'))
453449
Out[2]:
454450
a True
455451
b True
@@ -462,7 +458,7 @@ Other API Changes
462458

463459
.. code-block:: ipython
464460
465-
In [2]: pd.Series([0,1,2,3], list('abcd')) | pd.Series([4,4,4,4], list('abcd'))
461+
In [2]: pd.Series([0, 1, 2, 3], list('abcd')) | pd.Series([4, 4, 4, 4], list('abcd'))
466462
Out[2]:
467463
a 4
468464
b 5
@@ -680,7 +676,8 @@ Bug Fixes
680676

681677
.. ipython:: python
682678
683-
df1 = DataFrame({'x': Series(['a','b','c']), 'y': Series(['d','e','f'])})
679+
df1 = pd.DataFrame({'x': pd.Series(['a', 'b', 'c']),
680+
'y': pd.Series(['d', 'e', 'f'])})
684681
df2 = df1[['x']]
685682
df2['y'] = ['g', 'h', 'i']
686683

doc/source/whatsnew/v0.16.1.rst

+35-35
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ v0.16.1 (May 11, 2015)
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.16.0 and includes a a large number of
1510
bug fixes along several new features, enhancements, and performance improvements.
@@ -51,10 +46,10 @@ setting the index of a ``DataFrame/Series`` with a ``category`` dtype would conv
5146

5247
.. code-block:: ipython
5348
54-
In [1]: df = DataFrame({'A' : np.arange(6),
55-
...: 'B' : Series(list('aabbca')).astype('category',
56-
...: categories=list('cab'))
57-
...: })
49+
In [1]: df = pd.DataFrame({'A': np.arange(6),
50+
...: 'B': pd.Series(list('aabbca'))
51+
...: .astype('category', categories=list('cab'))
52+
...: })
5853
...:
5954
6055
In [2]: df
@@ -146,7 +141,7 @@ values NOT in the categories, similarly to how you can reindex ANY pandas index.
146141

147142
.. code-block:: ipython
148143
149-
In [12]: df2.reindex(['a','e'])
144+
In [12]: df2.reindex(['a', 'e'])
150145
Out[12]:
151146
A
152147
B
@@ -155,10 +150,10 @@ values NOT in the categories, similarly to how you can reindex ANY pandas index.
155150
a 5.0
156151
e NaN
157152
158-
In [13]: df2.reindex(['a','e']).index
159-
Out[13]: Index(['a', 'a', 'a', 'e'], dtype='object', name='B')
153+
In [13]: df2.reindex(['a', 'e']).index
154+
Out[13]: pd.Index(['a', 'a', 'a', 'e'], dtype='object', name='B')
160155
161-
In [14]: df2.reindex(pd.Categorical(['a','e'],categories=list('abcde')))
156+
In [14]: df2.reindex(pd.Categorical(['a', 'e'], categories=list('abcde')))
162157
Out[14]:
163158
A
164159
B
@@ -167,8 +162,11 @@ values NOT in the categories, similarly to how you can reindex ANY pandas index.
167162
a 5.0
168163
e NaN
169164
170-
In [15]: df2.reindex(pd.Categorical(['a','e'],categories=list('abcde'))).index
171-
Out[15]: CategoricalIndex(['a', 'a', 'a', 'e'], categories=['a', 'b', 'c', 'd', 'e'], ordered=False, name='B', dtype='category')
165+
In [15]: df2.reindex(pd.Categorical(['a', 'e'], categories=list('abcde'))).index
166+
Out[15]: pd.CategoricalIndex(['a', 'a', 'a', 'e'],
167+
categories=['a', 'b', 'c', 'd', 'e'],
168+
ordered=False, name='B',
169+
dtype='category')
172170
173171
See the :ref:`documentation <indexing.categoricalindex>` for more. (:issue:`7629`, :issue:`10038`, :issue:`10039`)
174172

@@ -230,7 +228,7 @@ enhancements make string operations easier and more consistent with standard pyt
230228

231229
.. ipython:: python
232230
233-
idx = Index([' jack', 'jill ', ' jesse ', 'frank'])
231+
idx = pd.Index([' jack', 'jill ', ' jesse ', 'frank'])
234232
idx.str.strip()
235233
236234
One special case for the `.str` accessor on ``Index`` is that if a string method returns ``bool``, the ``.str`` accessor
@@ -239,8 +237,8 @@ enhancements make string operations easier and more consistent with standard pyt
239237

240238
.. ipython:: python
241239
242-
idx = Index(['a1', 'a2', 'b1', 'b2'])
243-
s = Series(range(4), index=idx)
240+
idx = pd.Index(['a1', 'a2', 'b1', 'b2'])
241+
s = pd.Series(range(4), index=idx)
244242
s
245243
idx.str.startswith('a')
246244
s[s.index.str.startswith('a')]
@@ -258,15 +256,15 @@ enhancements make string operations easier and more consistent with standard pyt
258256

259257
.. ipython:: python
260258
261-
s = Series(['a,b', 'a,c', 'b,c'])
259+
s = pd.Series(['a,b', 'a,c', 'b,c'])
262260
263261
# return Series
264262
s.str.split(',')
265263
266264
# return DataFrame
267265
s.str.split(',', expand=True)
268266
269-
idx = Index(['a,b', 'a,c', 'b,c'])
267+
idx = pd.Index(['a,b', 'a,c', 'b,c'])
270268
271269
# return Index
272270
idx.str.split(',')
@@ -287,10 +285,9 @@ Other Enhancements
287285

288286
.. ipython:: python
289287
290-
from pandas.tseries.offsets import BusinessHour
291-
Timestamp('2014-08-01 09:00') + BusinessHour()
292-
Timestamp('2014-08-01 07:00') + BusinessHour()
293-
Timestamp('2014-08-01 16:30') + BusinessHour()
288+
pd.Timestamp('2014-08-01 09:00') + pd.tseries.offsets.BusinessHour()
289+
pd.Timestamp('2014-08-01 07:00') + pd.tseries.offsets.BusinessHour()
290+
pd.Timestamp('2014-08-01 16:30') + pd.tseries.offsets.BusinessHour()
294291
295292
- ``DataFrame.diff`` now takes an ``axis`` parameter that determines the direction of differencing (:issue:`9727`)
296293

@@ -302,7 +299,7 @@ Other Enhancements
302299

303300
.. ipython:: python
304301
305-
df = DataFrame(np.random.randn(3, 3), columns=['A', 'B', 'C'])
302+
df = pd.DataFrame(np.random.randn(3, 3), columns=['A', 'B', 'C'])
306303
df.drop(['A', 'X'], axis=1, errors='ignore')
307304
308305
- Add support for separating years and quarters using dashes, for
@@ -362,19 +359,19 @@ Previous Behavior
362359

363360
.. code-block:: ipython
364361
365-
In [2]: pd.Index(range(4),name='foo')
362+
In [2]: pd.Index(range(4), name='foo')
366363
Out[2]: Int64Index([0, 1, 2, 3], dtype='int64')
367364
368-
In [3]: pd.Index(range(104),name='foo')
365+
In [3]: pd.Index(range(104), name='foo')
369366
Out[3]: Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...], dtype='int64')
370367
371-
In [4]: pd.date_range('20130101',periods=4,name='foo',tz='US/Eastern')
368+
In [4]: pd.date_range('20130101', periods=4, name='foo', tz='US/Eastern')
372369
Out[4]:
373370
<class 'pandas.tseries.index.DatetimeIndex'>
374371
[2013-01-01 00:00:00-05:00, ..., 2013-01-04 00:00:00-05:00]
375372
Length: 4, Freq: D, Timezone: US/Eastern
376373
377-
In [5]: pd.date_range('20130101',periods=104,name='foo',tz='US/Eastern')
374+
In [5]: pd.date_range('20130101', periods=104, name='foo', tz='US/Eastern')
378375
Out[5]:
379376
<class 'pandas.tseries.index.DatetimeIndex'>
380377
[2013-01-01 00:00:00-05:00, ..., 2013-04-14 00:00:00-04:00]
@@ -388,12 +385,15 @@ New Behavior
388385
pd.Index(range(4), name='foo')
389386
pd.Index(range(30), name='foo')
390387
pd.Index(range(104), name='foo')
391-
pd.CategoricalIndex(['a','bb','ccc','dddd'], ordered=True, name='foobar')
392-
pd.CategoricalIndex(['a','bb','ccc','dddd']*10, ordered=True, name='foobar')
393-
pd.CategoricalIndex(['a','bb','ccc','dddd']*100, ordered=True, name='foobar')
394-
pd.date_range('20130101',periods=4, name='foo', tz='US/Eastern')
395-
pd.date_range('20130101',periods=25, freq='D')
396-
pd.date_range('20130101',periods=104, name='foo', tz='US/Eastern')
388+
pd.CategoricalIndex(['a', 'bb', 'ccc', 'dddd'],
389+
ordered=True, name='foobar')
390+
pd.CategoricalIndex(['a', 'bb', 'ccc', 'dddd'] * 10,
391+
ordered=True, name='foobar')
392+
pd.CategoricalIndex(['a', 'bb', 'ccc', 'dddd'] * 100,
393+
ordered=True, name='foobar')
394+
pd.date_range('20130101', periods=4, name='foo', tz='US/Eastern')
395+
pd.date_range('20130101', periods=25, freq='D')
396+
pd.date_range('20130101', periods=104, name='foo', tz='US/Eastern')
397397
398398
399399
.. _whatsnew_0161.performance:

0 commit comments

Comments
 (0)