Skip to content

Commit 4f482d5

Browse files
committed
Merge pull request #3815 from cpcloud/doc-build-fix
DOC/BLD: Fix a bunch of doc build warnings that weren't being previously caught
2 parents 24102ae + fdcaf13 commit 4f482d5

File tree

4 files changed

+96
-69
lines changed

4 files changed

+96
-69
lines changed

doc/source/dsintro.rst

+11-7
Original file line numberDiff line numberDiff line change
@@ -482,19 +482,23 @@ column-wise:
482482
.. ipython:: python
483483
484484
index = date_range('1/1/2000', periods=8)
485-
df = DataFrame(randn(8, 3), index=index,
486-
columns=['A', 'B', 'C'])
485+
df = DataFrame(randn(8, 3), index=index, columns=list('ABC'))
487486
df
488487
type(df['A'])
489488
df - df['A']
490489
491-
Technical purity aside, this case is so common in practice that supporting the
492-
special case is preferable to the alternative of forcing the user to transpose
493-
and do column-based alignment like so:
490+
.. warning::
494491

495-
.. ipython:: python
492+
.. code-block:: python
493+
494+
df - df['A']
495+
496+
is now deprecated and will be removed in a future release. The preferred way
497+
to replicate this behavior is
498+
499+
.. code-block:: python
496500
497-
(df.T - df['A']).T
501+
df.sub(df['A'], axis=0)
498502
499503
For explicit control over the matching and broadcasting behavior, see the
500504
section on :ref:`flexible binary operations <basics.binop>`.

doc/source/timeseries.rst

+57-43
Original file line numberDiff line numberDiff line change
@@ -930,89 +930,103 @@ They can be both positive and negative.
930930

931931
.. ipython:: python
932932
933-
from datetime import datetime, timedelta
934-
s = Series(date_range('2012-1-1', periods=3, freq='D'))
935-
td = Series([ timedelta(days=i) for i in range(3) ])
936-
df = DataFrame(dict(A = s, B = td))
937-
df
938-
df['C'] = df['A'] + df['B']
939-
df
940-
df.dtypes
941-
942-
s - s.max()
943-
s - datetime(2011,1,1,3,5)
944-
s + timedelta(minutes=5)
933+
from datetime import datetime, timedelta
934+
s = Series(date_range('2012-1-1', periods=3, freq='D'))
935+
td = Series([ timedelta(days=i) for i in range(3) ])
936+
df = DataFrame(dict(A = s, B = td))
937+
df
938+
df['C'] = df['A'] + df['B']
939+
df
940+
df.dtypes
941+
942+
s - s.max()
943+
s - datetime(2011,1,1,3,5)
944+
s + timedelta(minutes=5)
945945
946946
Getting scalar results from a ``timedelta64[ns]`` series
947947

948+
.. ipython:: python
949+
:suppress:
950+
951+
from distutils.version import LooseVersion
952+
948953
.. ipython:: python
949954
950955
y = s - s[0]
951956
y
952-
y.apply(lambda x: x.item().total_seconds())
953-
y.apply(lambda x: x.item().days)
954-
955-
.. note::
956957
957-
These operations are different in numpy 1.6.2 and in numpy >= 1.7. The ``timedelta64[ns]`` scalar
958-
type in 1.6.2 is much like a ``datetime.timedelta``, while in 1.7 it is a nanosecond based integer.
959-
A future version of pandas will make this transparent.
958+
if LooseVersion(np.__version__) <= '1.6.2':
959+
y.apply(lambda x: x.item().total_seconds())
960+
y.apply(lambda x: x.item().days)
961+
else:
962+
y.apply(lambda x: x / np.timedelta64(1, 's'))
963+
y.apply(lambda x: x / np.timedelta64(1, 'D'))
964+
965+
.. note::
960966

961-
These are the equivalent operation to above in numpy >= 1.7
967+
As you can see from the conditional statement above, these operations are
968+
different in numpy 1.6.2 and in numpy >= 1.7. The ``timedelta64[ns]`` scalar
969+
type in 1.6.2 is much like a ``datetime.timedelta``, while in 1.7 it is a
970+
nanosecond based integer. A future version of pandas will make this
971+
transparent.
962972

963-
``y.apply(lambda x: x.item()/np.timedelta64(1,'s'))``
973+
.. note::
964974

965-
``y.apply(lambda x: x.item()/np.timedelta64(1,'D'))``
975+
In numpy >= 1.7 dividing a ``timedelta64`` array by another ``timedelta64``
976+
array will yield an array with dtype ``np.float64``.
966977

967978
Series of timedeltas with ``NaT`` values are supported
968979

969980
.. ipython:: python
970981
971-
y = s - s.shift()
972-
y
982+
y = s - s.shift()
983+
y
984+
973985
The can be set to ``NaT`` using ``np.nan`` analagously to datetimes
974986

975987
.. ipython:: python
976988
977-
y[1] = np.nan
978-
y
989+
y[1] = np.nan
990+
y
979991
980992
Operands can also appear in a reversed order (a singluar object operated with a Series)
981993

982994
.. ipython:: python
983995
984-
s.max() - s
985-
datetime(2011,1,1,3,5) - s
986-
timedelta(minutes=5) + s
996+
s.max() - s
997+
datetime(2011,1,1,3,5) - s
998+
timedelta(minutes=5) + s
987999
9881000
Some timedelta numeric like operations are supported.
9891001

9901002
.. ipython:: python
9911003
992-
td - timedelta(minutes=5,seconds=5,microseconds=5)
1004+
td - timedelta(minutes=5, seconds=5, microseconds=5)
9931005
9941006
``min, max`` and the corresponding ``idxmin, idxmax`` operations are support on frames
9951007

9961008
.. ipython:: python
9971009
998-
df = DataFrame(dict(A = s - Timestamp('20120101')-timedelta(minutes=5,seconds=5),
999-
B = s - Series(date_range('2012-1-2', periods=3, freq='D'))))
1000-
df
1010+
A = s - Timestamp('20120101') - timedelta(minutes=5, seconds=5)
1011+
B = s - Series(date_range('2012-1-2', periods=3, freq='D'))
10011012
1013+
df = DataFrame(dict(A=A, B=B))
1014+
df
10021015
1003-
df.min()
1004-
df.min(axis=1)
1016+
df.min()
1017+
df.min(axis=1)
10051018
1006-
df.idxmin()
1007-
df.idxmax()
1019+
df.idxmin()
1020+
df.idxmax()
10081021
1009-
``min, max`` operations are support on series, these return a single element ``timedelta64[ns]`` Series (this avoids
1010-
having to deal with numpy timedelta64 issues). ``idxmin, idxmax`` are supported as well.
1022+
``min, max`` operations are support on series, these return a single element
1023+
``timedelta64[ns]`` Series (this avoids having to deal with numpy timedelta64
1024+
issues). ``idxmin, idxmax`` are supported as well.
10111025

10121026
.. ipython:: python
10131027
1014-
df.min().max()
1015-
df.min(axis=1).min()
1028+
df.min().max()
1029+
df.min(axis=1).min()
10161030
1017-
df.min().idxmax()
1018-
df.min(axis=1).idxmin()
1031+
df.min().idxmax()
1032+
df.min(axis=1).idxmin()

doc/source/v0.10.1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Retrieving unique values in an indexable or data column.
6969

7070
import warnings
7171
with warnings.catch_warnings():
72-
warnings.simplefilter('ignore', category=DeprecationWarning)
72+
warnings.simplefilter('ignore', category=UserWarning)
7373
store.unique('df','index')
7474
store.unique('df','string')
7575

doc/source/visualization.rst

+27-18
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
:suppress:
66
77
import numpy as np
8+
from numpy.random import randn, rand, randint
89
np.random.seed(123456)
9-
from pandas import *
10+
from pandas import DataFrame, Series, date_range, options
1011
import pandas.util.testing as tm
11-
randn = np.random.randn
1212
np.set_printoptions(precision=4, suppress=True)
1313
import matplotlib.pyplot as plt
1414
plt.close('all')
15-
options.display.mpl_style='default'
15+
options.display.mpl_style = 'default'
1616
1717
************************
1818
Plotting with matplotlib
@@ -60,8 +60,7 @@ On DataFrame, ``plot`` is a convenience to plot all of the columns with labels:
6060

6161
.. ipython:: python
6262
63-
df = DataFrame(randn(1000, 4), index=ts.index,
64-
columns=['A', 'B', 'C', 'D'])
63+
df = DataFrame(randn(1000, 4), index=ts.index, columns=list('ABCD'))
6564
df = df.cumsum()
6665
6766
@savefig frame_plot_basic.png width=6in
@@ -101,7 +100,7 @@ You can plot one column versus another using the `x` and `y` keywords in
101100
102101
plt.figure()
103102
104-
df3 = DataFrame(np.random.randn(1000, 2), columns=['B', 'C']).cumsum()
103+
df3 = DataFrame(randn(1000, 2), columns=['B', 'C']).cumsum()
105104
df3['A'] = Series(range(len(df)))
106105
107106
@savefig df_plot_xy.png width=6in
@@ -169,7 +168,7 @@ Here is the default behavior, notice how the x-axis tick labelling is performed:
169168
df.A.plot()
170169
171170
172-
Using the ``x_compat`` parameter, you can suppress this bevahior:
171+
Using the ``x_compat`` parameter, you can suppress this behavior:
173172

174173
.. ipython:: python
175174
@@ -200,6 +199,15 @@ Targeting different subplots
200199

201200
You can pass an ``ax`` argument to ``Series.plot`` to plot on a particular axis:
202201

202+
.. ipython:: python
203+
:suppress:
204+
205+
ts = Series(randn(1000), index=date_range('1/1/2000', periods=1000))
206+
ts = ts.cumsum()
207+
208+
df = DataFrame(randn(1000, 4), index=ts.index, columns=list('ABCD'))
209+
df = df.cumsum()
210+
203211
.. ipython:: python
204212
205213
fig, axes = plt.subplots(nrows=2, ncols=2)
@@ -210,6 +218,7 @@ You can pass an ``ax`` argument to ``Series.plot`` to plot on a particular axis:
210218
@savefig series_plot_multi.png width=6in
211219
df['D'].plot(ax=axes[1,1]); axes[1,1].set_title('D')
212220
221+
213222
.. _visualization.other:
214223

215224
Other plotting features
@@ -239,7 +248,7 @@ bar plot:
239248
240249
.. ipython:: python
241250
242-
df2 = DataFrame(np.random.rand(10, 4), columns=['a', 'b', 'c', 'd'])
251+
df2 = DataFrame(rand(10, 4), columns=['a', 'b', 'c', 'd'])
243252
244253
@savefig bar_plot_multi_ex.png width=5in
245254
df2.plot(kind='bar');
@@ -298,10 +307,10 @@ New since 0.10.0, the ``by`` keyword can be specified to plot grouped histograms
298307
299308
.. ipython:: python
300309
301-
data = Series(np.random.randn(1000))
310+
data = Series(randn(1000))
302311
303312
@savefig grouped_hist.png width=6in
304-
data.hist(by=np.random.randint(0, 4, 1000))
313+
data.hist(by=randint(0, 4, 1000))
305314
306315
307316
.. _visualization.box:
@@ -317,7 +326,7 @@ a uniform random variable on [0,1).
317326

318327
.. ipython:: python
319328
320-
df = DataFrame(np.random.rand(10,5))
329+
df = DataFrame(rand(10,5))
321330
plt.figure();
322331
323332
@savefig box_plot_ex.png width=6in
@@ -328,7 +337,7 @@ groupings. For instance,
328337

329338
.. ipython:: python
330339
331-
df = DataFrame(np.random.rand(10,2), columns=['Col1', 'Col2'] )
340+
df = DataFrame(rand(10,2), columns=['Col1', 'Col2'] )
332341
df['X'] = Series(['A','A','A','A','A','B','B','B','B','B'])
333342
334343
plt.figure();
@@ -341,7 +350,7 @@ columns:
341350

342351
.. ipython:: python
343352
344-
df = DataFrame(np.random.rand(10,3), columns=['Col1', 'Col2', 'Col3'])
353+
df = DataFrame(rand(10,3), columns=['Col1', 'Col2', 'Col3'])
345354
df['X'] = Series(['A','A','A','A','A','B','B','B','B','B'])
346355
df['Y'] = Series(['A','B','A','B','A','B','A','B','A','B'])
347356
@@ -361,7 +370,7 @@ Scatter plot matrix
361370
.. ipython:: python
362371
363372
from pandas.tools.plotting import scatter_matrix
364-
df = DataFrame(np.random.randn(1000, 4), columns=['a', 'b', 'c', 'd'])
373+
df = DataFrame(randn(1000, 4), columns=['a', 'b', 'c', 'd'])
365374
366375
@savefig scatter_matrix_kde.png width=6in
367376
scatter_matrix(df, alpha=0.2, figsize=(6, 6), diagonal='kde')
@@ -378,7 +387,7 @@ setting `kind='kde'`:
378387
379388
.. ipython:: python
380389
381-
ser = Series(np.random.randn(1000))
390+
ser = Series(randn(1000))
382391
383392
@savefig kde_plot.png width=6in
384393
ser.plot(kind='kde')
@@ -444,7 +453,7 @@ implies that the underlying data are not random.
444453
445454
plt.figure()
446455
447-
data = Series(0.1 * np.random.random(1000) +
456+
data = Series(0.1 * rand(1000) +
448457
0.9 * np.sin(np.linspace(-99 * np.pi, 99 * np.pi, num=1000)))
449458
450459
@savefig lag_plot.png width=6in
@@ -467,7 +476,7 @@ confidence band.
467476
468477
plt.figure()
469478
470-
data = Series(0.7 * np.random.random(1000) +
479+
data = Series(0.7 * rand(1000) +
471480
0.3 * np.sin(np.linspace(-9 * np.pi, 9 * np.pi, num=1000)))
472481
473482
@savefig autocorrelation_plot.png width=6in
@@ -488,7 +497,7 @@ are what constitutes the bootstrap plot.
488497
489498
from pandas.tools.plotting import bootstrap_plot
490499
491-
data = Series(np.random.random(1000))
500+
data = Series(rand(1000))
492501
493502
@savefig bootstrap_plot.png width=6in
494503
bootstrap_plot(data, size=50, samples=500, color='grey')

0 commit comments

Comments
 (0)