Skip to content

DOC: fix various warnings and errors in the docs (from deprecations/api changes #19763

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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion doc/source/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Passing a list of labels or tuples works similar to reindexing:

df.loc[[('bar', 'two'), ('qux', 'one')]]

.. info::
.. note::

It is important to note that tuples and lists are not treated identically
in pandas when it comes to indexing. Whereas a tuple is interpreted as one
Expand Down
2 changes: 1 addition & 1 deletion doc/source/dsintro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ to be inserted (for example, a ``Series`` or NumPy array), or a function
of one argument to be called on the ``DataFrame``. A *copy* of the original
DataFrame is returned, with the new values inserted.

.. versionmodified:: 0.23.0
.. versionchanged:: 0.23.0

Starting with Python 3.6 the order of ``**kwargs`` is preserved. This allows
for *dependent* assignment, where an expression later in ``**kwargs`` can refer
Expand Down
1 change: 1 addition & 0 deletions doc/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,7 @@ is not round-trippable, nor are any names beginning with 'level_' within a
indicate missing values and the subsequent read cannot distinguish the intent.

.. ipython:: python
:okwarning:

df.index.name = 'index'
df.to_json('test.json', orient='table')
Expand Down
26 changes: 17 additions & 9 deletions doc/source/whatsnew/v0.10.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,23 @@ N Dimensional Panels (Experimental)
Adding experimental support for Panel4D and factory functions to create n-dimensional named panels.
:ref:`Docs <dsintro.panel4d>` for NDim. Here is a taste of what to expect.

.. ipython:: python
:okwarning:

p4d = Panel4D(randn(2, 2, 5, 4),
labels=['Label1','Label2'],
items=['Item1', 'Item2'],
major_axis=date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])
p4d
.. code-block:: ipython

In [58]: p4d = Panel4D(randn(2, 2, 5, 4),
....: labels=['Label1','Label2'],
....: items=['Item1', 'Item2'],
....: major_axis=date_range('1/1/2000', periods=5),
....: minor_axis=['A', 'B', 'C', 'D'])
....:

In [59]: p4d
Out[59]:
<class 'pandas.core.panelnd.Panel4D'>
Dimensions: 2 (labels) x 2 (items) x 5 (major_axis) x 4 (minor_axis)
Labels axis: Label1 to Label2
Items axis: Item1 to Item2
Major_axis axis: 2000-01-01 00:00:00 to 2000-01-05 00:00:00
Minor_axis axis: A to D



Expand Down
37 changes: 28 additions & 9 deletions doc/source/whatsnew/v0.13.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,44 @@ API changes
applied would be called with an empty ``Series`` to guess whether a
``Series`` or ``DataFrame`` should be returned:

.. ipython:: python
.. code-block:: ipython

In [32]: def applied_func(col):
....: print("Apply function being called with: ", col)
....: return col.sum()
....:

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

empty = DataFrame(columns=['a', 'b'])
empty.apply(applied_func)
In [34]: empty.apply(applied_func)
Apply function being called with: Series([], Length: 0, dtype: float64)
Out[34]:
a NaN
b NaN
Length: 2, dtype: float64

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

.. ipython:: python
.. code-block:: ipython

In [35]: empty.apply(applied_func, reduce=True)
Out[35]:
a NaN
b NaN
Length: 2, dtype: float64

In [36]: empty.apply(applied_func, reduce=False)
Out[36]:
Empty DataFrame
Columns: [a, b]
Index: []

[0 rows x 2 columns]

empty.apply(applied_func, reduce=True)
empty.apply(applied_func, reduce=False)

Prior Version Deprecations/Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.15.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ Other:

idx = MultiIndex.from_product([['a'], range(3), list("pqr")], names=['foo', 'bar', 'baz'])
idx.set_names('qux', level=0)
idx.set_names(['qux','baz'], level=[0,1])
idx.set_names(['qux','corge'], level=[0,1])
idx.set_levels(['a','b','c'], level='bar')
idx.set_levels([['a','b','c'],[1,2,3]], level=[1,2])

Expand Down
13 changes: 5 additions & 8 deletions doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -894,17 +894,14 @@ imported. Matplotlib plot methods (``plt.plot``, ``ax.plot``, ...), will not
nicely format the x-axis for ``DatetimeIndex`` or ``PeriodIndex`` values. You
must explicitly register these methods:

.. ipython:: python

from pandas.tseries import converter
converter.register()

fig, ax = plt.subplots()
plt.plot(pd.date_range('2017', periods=6), range(6))

Pandas built-in ``Series.plot`` and ``DataFrame.plot`` *will* register these
converters on first-use (:issue:17710).

.. note::

This change has been temporarily reverted in pandas 0.21.1,
for more details see :ref:`here <whatsnew_0211.converters>`.

.. _whatsnew_0210.api:

Other API Changes
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ A ``DataFrame`` can now be written to and subsequently read back via JSON while
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.

.. ipython:: python
:okwarning:

df.index.name = 'index'
df.to_json('test.json', orient='table')
Expand Down
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.8.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ nanosecond support (the ``nanosecond`` field store the nanosecond value between
``DatetimeIndex`` to regular NumPy arrays.

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

.. ipython:: python

stamp_array = rng.asobject
stamp_array = rng.astype(object)
stamp_array
stamp_array[5]

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
- if `axis` is 1 or `'columns'` then `by` may contain column
levels and/or index labels

.. versionmodified:: 0.23.0
.. versionchanged:: 0.23.0
Allow specifying index or column level names.""",
versionadded_to_excel='',
optional_labels="""labels : array-like, optional
Expand Down Expand Up @@ -2696,7 +2696,7 @@ def assign(self, **kwargs):
or modified columns. All items are computed first, and then assigned
in alphabetical order.

.. versionmodified :: 0.23.0
.. versionchanged :: 0.23.0

Keyword argument order is maintained for Python 3.6 and later.

Expand Down