Skip to content

Commit 8374a1d

Browse files
datapythonistajorisvandenbossche
authored andcommitted
DOC: Fixing some more warnings (#26810)
1 parent 14ee9de commit 8374a1d

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

doc/source/user_guide/advanced.rst

+2
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ faster than fancy indexing.
703703
%timeit arr[indexer]
704704
%timeit arr.take(indexer, axis=0)
705705
706+
.. ipython:: python
707+
706708
ser = pd.Series(arr[:, 0])
707709
%timeit ser.iloc[indexer]
708710
%timeit ser.take(indexer)

doc/source/user_guide/cookbook.rst

-5
Original file line numberDiff line numberDiff line change
@@ -1260,24 +1260,19 @@ The `method` argument within `DataFrame.corr` can accept a callable in addition
12601260
n = len(x)
12611261
a = np.zeros(shape=(n, n))
12621262
b = np.zeros(shape=(n, n))
1263-
12641263
for i in range(n):
12651264
for j in range(i + 1, n):
12661265
a[i, j] = abs(x[i] - x[j])
12671266
b[i, j] = abs(y[i] - y[j])
1268-
12691267
a += a.T
12701268
b += b.T
1271-
12721269
a_bar = np.vstack([np.nanmean(a, axis=0)] * n)
12731270
b_bar = np.vstack([np.nanmean(b, axis=0)] * n)
1274-
12751271
A = a - a_bar - a_bar.T + np.full(shape=(n, n), fill_value=a_bar.mean())
12761272
B = b - b_bar - b_bar.T + np.full(shape=(n, n), fill_value=b_bar.mean())
12771273
cov_ab = np.sqrt(np.nansum(A * B)) / n
12781274
std_a = np.sqrt(np.sqrt(np.nansum(A**2)) / n)
12791275
std_b = np.sqrt(np.sqrt(np.nansum(B**2)) / n)
1280-
12811276
return cov_ab / std_a / std_b
12821277
12831278
df = pd.DataFrame(np.random.normal(size=(100, 3)))

doc/source/user_guide/io.rst

+4
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,7 @@ See the documentation for `pyarrow <https://arrow.apache.org/docs/python/>`__ an
47034703
Write to a parquet file.
47044704

47054705
.. ipython:: python
4706+
:okwarning:
47064707
47074708
df.to_parquet('example_pa.parquet', engine='pyarrow')
47084709
df.to_parquet('example_fp.parquet', engine='fastparquet')
@@ -4720,6 +4721,7 @@ Read from a parquet file.
47204721
Read only certain columns of a parquet file.
47214722

47224723
.. ipython:: python
4724+
:okwarning:
47234725
47244726
result = pd.read_parquet('example_fp.parquet',
47254727
engine='fastparquet', columns=['a', 'b'])
@@ -4742,6 +4744,7 @@ Serializing a ``DataFrame`` to parquet may include the implicit index as one or
47424744
more columns in the output file. Thus, this code:
47434745

47444746
.. ipython:: python
4747+
:okwarning:
47454748
47464749
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
47474750
df.to_parquet('test.parquet', engine='pyarrow')
@@ -4758,6 +4761,7 @@ If you want to omit a dataframe's indexes when writing, pass ``index=False`` to
47584761
:func:`~pandas.DataFrame.to_parquet`:
47594762

47604763
.. ipython:: python
4764+
:okwarning:
47614765
47624766
df.to_parquet('test.parquet', index=False)
47634767

doc/source/user_guide/missing_data.rst

+13-4
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,21 @@ that, by default, performs linear interpolation at missing data points.
348348
np.random.seed(123456)
349349
idx = pd.date_range('1/1/2000', periods=100, freq='BM')
350350
ts = pd.Series(np.random.randn(100), index=idx)
351-
ts[1:20] = np.nan
351+
ts[1:5] = np.nan
352+
ts[20:30] = np.nan
352353
ts[60:80] = np.nan
353354
ts = ts.cumsum()
354355
355356
.. ipython:: python
356357
357358
ts
358359
ts.count()
360+
@savefig series_before_interpolate.png
361+
ts.plot()
362+
363+
.. ipython:: python
364+
365+
ts.interpolate()
359366
ts.interpolate().count()
360367
361368
@savefig series_interpolate.png
@@ -435,9 +442,9 @@ Compare several methods:
435442
436443
np.random.seed(2)
437444
438-
ser = pd.Series(np.arange(1, 10.1, .25)**2 + np.random.randn(37))
439-
bad = np.array([4, 13, 14, 15, 16, 17, 18, 20, 29])
440-
ser[bad] = np.nan
445+
ser = pd.Series(np.arange(1, 10.1, .25) ** 2 + np.random.randn(37))
446+
missing = np.array([4, 13, 14, 15, 16, 17, 18, 20, 29])
447+
ser[missing] = np.nan
441448
methods = ['linear', 'quadratic', 'cubic']
442449
443450
df = pd.DataFrame({m: ser.interpolate(method=m) for m in methods})
@@ -451,6 +458,7 @@ You can mix pandas' ``reindex`` and ``interpolate`` methods to interpolate
451458
at the new values.
452459

453460
.. ipython:: python
461+
:okexcept:
454462
455463
ser = pd.Series(np.sort(np.random.uniform(size=100)))
456464
@@ -476,6 +484,7 @@ filled since the last valid observation:
476484
477485
ser = pd.Series([np.nan, np.nan, 5, np.nan, np.nan,
478486
np.nan, 13, np.nan, np.nan])
487+
ser
479488
480489
# fill all consecutive values in a forward direction
481490
ser.interpolate()

doc/source/whatsnew/v0.17.0.rst

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ v0.17.0 (October 9, 2015)
55

66
{{ header }}
77

8-
.. ipython:: python
9-
:suppress:
10-
11-
128

139
This is a major release from 0.16.2 and includes a small number of API changes, several new features,
1410
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all

doc/source/whatsnew/v0.17.1.rst

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ v0.17.1 (November 21, 2015)
55

66
{{ header }}
77

8-
.. ipython:: python
9-
:suppress:
10-
11-
128

139
.. note::
1410

0 commit comments

Comments
 (0)