Skip to content

DOC: suppress warning + fix reshape example #8034

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 1 commit into from
Aug 15, 2014
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
1 change: 1 addition & 0 deletions doc/source/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ You can control the action of a chained assignment via the option ``mode.chained
which can take the values ``['raise','warn',None]``, where showing a warning is the default.

.. ipython:: python
:okwarning:

dfb = DataFrame({'a' : ['one', 'one', 'two',
'three', 'two', 'one', 'six'],
Expand Down
20 changes: 11 additions & 9 deletions doc/source/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ unstacks the **last level**:
stacked.unstack(1)
stacked.unstack(0)
.. _reshaping.unstack_by_name:

If the indexes have names, you can use the level names instead of specifying
the level numbers:

.. ipython:: python
stacked.unstack('second')
Notice that the ``stack`` and ``unstack`` methods implicitly sort the index
levels involved. Hence a call to ``stack`` and then ``unstack``, or viceversa,
will result in a **sorted** copy of the original DataFrame or Series:
Expand All @@ -165,15 +174,6 @@ will result in a **sorted** copy of the original DataFrame or Series:
while the above code will raise a ``TypeError`` if the call to ``sort`` is
removed.

.. _reshaping.unstack_by_name:

If the indexes have names, you can use the level names instead of specifying
the level numbers:

.. ipython:: python
stacked.unstack('second')
.. _reshaping.stack_multiple:

Multiple Levels
Expand Down Expand Up @@ -218,6 +218,8 @@ calling ``sortlevel``, of course). Here is a more complex example:
columns = MultiIndex.from_tuples([('A', 'cat'), ('B', 'dog'),
('B', 'cat'), ('A', 'dog')],
names=['exp', 'animal'])
index = MultiIndex.from_product([('bar', 'baz', 'foo', 'qux'), ('one', 'two')],
names=['first', 'second'])
df = DataFrame(randn(8, 4), index=index, columns=columns)
df2 = df.ix[[0, 1, 2, 4, 5, 7]]
df2
Expand Down