Skip to content

Commit c05f3c1

Browse files
DOC: fix various warnings and errors in the docs (from deprecations/api changes) (#19763)
1 parent af5e8ec commit c05f3c1

File tree

10 files changed

+59
-33
lines changed

10 files changed

+59
-33
lines changed

doc/source/advanced.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ Passing a list of labels or tuples works similar to reindexing:
274274
275275
df.loc[[('bar', 'two'), ('qux', 'one')]]
276276
277-
.. info::
277+
.. note::
278278

279279
It is important to note that tuples and lists are not treated identically
280280
in pandas when it comes to indexing. Whereas a tuple is interpreted as one

doc/source/dsintro.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ to be inserted (for example, a ``Series`` or NumPy array), or a function
506506
of one argument to be called on the ``DataFrame``. A *copy* of the original
507507
DataFrame is returned, with the new values inserted.
508508

509-
.. versionmodified:: 0.23.0
509+
.. versionchanged:: 0.23.0
510510

511511
Starting with Python 3.6 the order of ``**kwargs`` is preserved. This allows
512512
for *dependent* assignment, where an expression later in ``**kwargs`` can refer

doc/source/io.rst

+1
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,7 @@ is not round-trippable, nor are any names beginning with 'level_' within a
22622262
indicate missing values and the subsequent read cannot distinguish the intent.
22632263

22642264
.. ipython:: python
2265+
:okwarning:
22652266
22662267
df.index.name = 'index'
22672268
df.to_json('test.json', orient='table')

doc/source/whatsnew/v0.10.0.txt

+17-9
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,23 @@ N Dimensional Panels (Experimental)
411411
Adding experimental support for Panel4D and factory functions to create n-dimensional named panels.
412412
:ref:`Docs <dsintro.panel4d>` for NDim. Here is a taste of what to expect.
413413

414-
.. ipython:: python
415-
:okwarning:
416-
417-
p4d = Panel4D(randn(2, 2, 5, 4),
418-
labels=['Label1','Label2'],
419-
items=['Item1', 'Item2'],
420-
major_axis=date_range('1/1/2000', periods=5),
421-
minor_axis=['A', 'B', 'C', 'D'])
422-
p4d
414+
.. code-block:: ipython
415+
416+
In [58]: p4d = Panel4D(randn(2, 2, 5, 4),
417+
....: labels=['Label1','Label2'],
418+
....: items=['Item1', 'Item2'],
419+
....: major_axis=date_range('1/1/2000', periods=5),
420+
....: minor_axis=['A', 'B', 'C', 'D'])
421+
....:
422+
423+
In [59]: p4d
424+
Out[59]:
425+
<class 'pandas.core.panelnd.Panel4D'>
426+
Dimensions: 2 (labels) x 2 (items) x 5 (major_axis) x 4 (minor_axis)
427+
Labels axis: Label1 to Label2
428+
Items axis: Item1 to Item2
429+
Major_axis axis: 2000-01-01 00:00:00 to 2000-01-05 00:00:00
430+
Minor_axis axis: A to D
423431

424432

425433

doc/source/whatsnew/v0.13.1.txt

+28-9
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,44 @@ API changes
140140
applied would be called with an empty ``Series`` to guess whether a
141141
``Series`` or ``DataFrame`` should be returned:
142142

143-
.. ipython:: python
143+
.. code-block:: ipython
144+
145+
In [32]: def applied_func(col):
146+
....: print("Apply function being called with: ", col)
147+
....: return col.sum()
148+
....:
144149

145-
def applied_func(col):
146-
print("Apply function being called with: ", col)
147-
return col.sum()
150+
In [33]: empty = DataFrame(columns=['a', 'b'])
148151

149-
empty = DataFrame(columns=['a', 'b'])
150-
empty.apply(applied_func)
152+
In [34]: empty.apply(applied_func)
153+
Apply function being called with: Series([], Length: 0, dtype: float64)
154+
Out[34]:
155+
a NaN
156+
b NaN
157+
Length: 2, dtype: float64
151158

152159
Now, when ``apply`` is called on an empty ``DataFrame``: if the ``reduce``
153160
argument is ``True`` a ``Series`` will returned, if it is ``False`` a
154161
``DataFrame`` will be returned, and if it is ``None`` (the default) the
155162
function being applied will be called with an empty series to try and guess
156163
the return type.
157164

158-
.. ipython:: python
165+
.. code-block:: ipython
166+
167+
In [35]: empty.apply(applied_func, reduce=True)
168+
Out[35]:
169+
a NaN
170+
b NaN
171+
Length: 2, dtype: float64
172+
173+
In [36]: empty.apply(applied_func, reduce=False)
174+
Out[36]:
175+
Empty DataFrame
176+
Columns: [a, b]
177+
Index: []
178+
179+
[0 rows x 2 columns]
159180

160-
empty.apply(applied_func, reduce=True)
161-
empty.apply(applied_func, reduce=False)
162181

163182
Prior Version Deprecations/Changes
164183
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/source/whatsnew/v0.15.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ Other:
10441044

10451045
idx = MultiIndex.from_product([['a'], range(3), list("pqr")], names=['foo', 'bar', 'baz'])
10461046
idx.set_names('qux', level=0)
1047-
idx.set_names(['qux','baz'], level=[0,1])
1047+
idx.set_names(['qux','corge'], level=[0,1])
10481048
idx.set_levels(['a','b','c'], level='bar')
10491049
idx.set_levels([['a','b','c'],[1,2,3]], level=[1,2])
10501050

doc/source/whatsnew/v0.21.0.txt

+5-8
Original file line numberDiff line numberDiff line change
@@ -894,17 +894,14 @@ imported. Matplotlib plot methods (``plt.plot``, ``ax.plot``, ...), will not
894894
nicely format the x-axis for ``DatetimeIndex`` or ``PeriodIndex`` values. You
895895
must explicitly register these methods:
896896

897-
.. ipython:: python
898-
899-
from pandas.tseries import converter
900-
converter.register()
901-
902-
fig, ax = plt.subplots()
903-
plt.plot(pd.date_range('2017', periods=6), range(6))
904-
905897
Pandas built-in ``Series.plot`` and ``DataFrame.plot`` *will* register these
906898
converters on first-use (:issue:17710).
907899

900+
.. note::
901+
902+
This change has been temporarily reverted in pandas 0.21.1,
903+
for more details see :ref:`here <whatsnew_0211.converters>`.
904+
908905
.. _whatsnew_0210.api:
909906

910907
Other API Changes

doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ A ``DataFrame`` can now be written to and subsequently read back via JSON while
211211
Please note that the string `index` is not supported with the round trip format, as it is used by default in ``write_json`` to indicate a missing index name.
212212

213213
.. ipython:: python
214+
:okwarning:
214215

215216
df.index.name = 'index'
216217
df.to_json('test.json', orient='table')

doc/source/whatsnew/v0.8.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@ nanosecond support (the ``nanosecond`` field store the nanosecond value between
217217
``DatetimeIndex`` to regular NumPy arrays.
218218

219219
If you have code that requires an array of ``datetime.datetime`` objects, you
220-
have a couple of options. First, the ``asobject`` property of ``DatetimeIndex``
220+
have a couple of options. First, the ``astype(object)`` method of ``DatetimeIndex``
221221
produces an array of ``Timestamp`` objects:
222222

223223
.. ipython:: python
224224

225-
stamp_array = rng.asobject
225+
stamp_array = rng.astype(object)
226226
stamp_array
227227
stamp_array[5]
228228

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
- if `axis` is 1 or `'columns'` then `by` may contain column
115115
levels and/or index labels
116116
117-
.. versionmodified:: 0.23.0
117+
.. versionchanged:: 0.23.0
118118
Allow specifying index or column level names.""",
119119
versionadded_to_excel='',
120120
optional_labels="""labels : array-like, optional
@@ -2696,7 +2696,7 @@ def assign(self, **kwargs):
26962696
or modified columns. All items are computed first, and then assigned
26972697
in alphabetical order.
26982698
2699-
.. versionmodified :: 0.23.0
2699+
.. versionchanged :: 0.23.0
27002700
27012701
Keyword argument order is maintained for Python 3.6 and later.
27022702

0 commit comments

Comments
 (0)