Skip to content

DOC: Fixing some more warnings #26810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/source/getting_started/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ See the :ref:`Plotting <visualization>` docs.

.. ipython:: python

# register converters to display dates in plots
pd.plotting.register_matplotlib_converters()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be added, the warning in the log is indicating a recent regression, see #26770


ts = pd.Series(np.random.randn(1000),
index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
Expand Down
2 changes: 2 additions & 0 deletions doc/source/user_guide/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ faster than fancy indexing.
%timeit arr[indexer]
%timeit arr.take(indexer, axis=0)

.. ipython:: python

ser = pd.Series(arr[:, 0])
%timeit ser.iloc[indexer]
%timeit ser.take(indexer)
Expand Down
5 changes: 0 additions & 5 deletions doc/source/user_guide/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1260,24 +1260,19 @@ The `method` argument within `DataFrame.corr` can accept a callable in addition
n = len(x)
a = np.zeros(shape=(n, n))
b = np.zeros(shape=(n, n))

for i in range(n):
for j in range(i + 1, n):
a[i, j] = abs(x[i] - x[j])
b[i, j] = abs(y[i] - y[j])

a += a.T
b += b.T

a_bar = np.vstack([np.nanmean(a, axis=0)] * n)
b_bar = np.vstack([np.nanmean(b, axis=0)] * n)

A = a - a_bar - a_bar.T + np.full(shape=(n, n), fill_value=a_bar.mean())
B = b - b_bar - b_bar.T + np.full(shape=(n, n), fill_value=b_bar.mean())
cov_ab = np.sqrt(np.nansum(A * B)) / n
std_a = np.sqrt(np.sqrt(np.nansum(A**2)) / n)
std_b = np.sqrt(np.sqrt(np.nansum(B**2)) / n)

return cov_ab / std_a / std_b

df = pd.DataFrame(np.random.normal(size=(100, 3)))
Expand Down
4 changes: 4 additions & 0 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4703,6 +4703,7 @@ See the documentation for `pyarrow <https://arrow.apache.org/docs/python/>`__ an
Write to a parquet file.

.. ipython:: python
:okwarning:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is fine.

Although, we should actually make sure to install the latest version of pyarrow (where this is fixed), but for some reason conda installs 0.11 instead of 0.13


df.to_parquet('example_pa.parquet', engine='pyarrow')
df.to_parquet('example_fp.parquet', engine='fastparquet')
Expand All @@ -4720,6 +4721,7 @@ Read from a parquet file.
Read only certain columns of a parquet file.

.. ipython:: python
:okwarning:

result = pd.read_parquet('example_fp.parquet',
engine='fastparquet', columns=['a', 'b'])
Expand All @@ -4742,6 +4744,7 @@ Serializing a ``DataFrame`` to parquet may include the implicit index as one or
more columns in the output file. Thus, this code:

.. ipython:: python
:okwarning:

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

.. ipython:: python
:okwarning:

df.to_parquet('test.parquet', index=False)

Expand Down
18 changes: 13 additions & 5 deletions doc/source/user_guide/missing_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,21 @@ that, by default, performs linear interpolation at missing data points.
np.random.seed(123456)
idx = pd.date_range('1/1/2000', periods=100, freq='BM')
ts = pd.Series(np.random.randn(100), index=idx)
ts[1:20] = np.nan
ts[1:5] = np.nan
ts[20:30] = np.nan
ts[60:80] = np.nan
ts = ts.cumsum()

.. ipython:: python

ts
ts.count()
@savefig series_before_interpolate.png
ts.interpolate().plot()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be without the interpolate? As the above line is already included a couple of lines below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, I saw it when reviewing the rendered page, and thought I fixed it, but seems like I didn't


.. ipython:: python

ts.interpolate()
ts.interpolate().count()

@savefig series_interpolate.png
Expand Down Expand Up @@ -435,9 +442,9 @@ Compare several methods:

np.random.seed(2)

ser = pd.Series(np.arange(1, 10.1, .25)**2 + np.random.randn(37))
bad = np.array([4, 13, 14, 15, 16, 17, 18, 20, 29])
ser[bad] = np.nan
ser = pd.Series(np.arange(1, 10.1, .25) ** 2 + np.random.randn(37))
missing = np.array([4, 13, 14, 15, 16, 17, 18, 20, 29])
ser[missing] = np.nan
methods = ['linear', 'quadratic', 'cubic']

df = pd.DataFrame({m: ser.interpolate(method=m) for m in methods})
Expand All @@ -455,7 +462,7 @@ at the new values.
ser = pd.Series(np.sort(np.random.uniform(size=100)))

# interpolate at new_index
new_index = ser.index | pd.Index([49.25, 49.5, 49.75, 50.25, 50.5, 50.75])
new_index = pd.Float64Index(ser.index | pd.Index([49.25, 49.5, 49.75, 50.25, 50.5, 50.75]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this change out.

Yes, it is annoying that it fails, but this should work and is a regression we need to fix (and we actually catched this due to the docs).

If this is the final error that is remaining and blocking that we can start failing CI for errors/warnings in the docs, then we can do that or add a temporary :okexcept:, but we are not there yet I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding an :okexcept:, I'm trying to make this the last time in my life I fix lots of pandas doc warnings (it's not the first), so hopefully we can add the check soon

interp_s = ser.reindex(new_index).interpolate(method='pchip')
interp_s[49:51]

Expand All @@ -476,6 +483,7 @@ filled since the last valid observation:

ser = pd.Series([np.nan, np.nan, 5, np.nan, np.nan,
np.nan, 13, np.nan, np.nan])
ser

# fill all consecutive values in a forward direction
ser.interpolate()
Expand Down
4 changes: 0 additions & 4 deletions doc/source/whatsnew/v0.17.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ v0.17.0 (October 9, 2015)

{{ header }}

.. ipython:: python
:suppress:



This is a major release from 0.16.2 and includes a small number of API changes, several new features,
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
Expand Down
4 changes: 0 additions & 4 deletions doc/source/whatsnew/v0.17.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ v0.17.1 (November 21, 2015)

{{ header }}

.. ipython:: python
:suppress:



.. note::

Expand Down