Skip to content

Commit 6796139

Browse files
Merge pull request #8034 from jorisvandenbossche/doc-fixes4
DOC: suppress warning + fix reshape example
2 parents 441c585 + 22d31a2 commit 6796139

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

doc/source/indexing.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ You can control the action of a chained assignment via the option ``mode.chained
14761476
which can take the values ``['raise','warn',None]``, where showing a warning is the default.
14771477
14781478
.. ipython:: python
1479+
:okwarning:
14791480
14801481
dfb = DataFrame({'a' : ['one', 'one', 'two',
14811482
'three', 'two', 'one', 'six'],

doc/source/reshaping.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ unstacks the **last level**:
151151
stacked.unstack(1)
152152
stacked.unstack(0)
153153
154+
.. _reshaping.unstack_by_name:
155+
156+
If the indexes have names, you can use the level names instead of specifying
157+
the level numbers:
158+
159+
.. ipython:: python
160+
161+
stacked.unstack('second')
162+
154163
Notice that the ``stack`` and ``unstack`` methods implicitly sort the index
155164
levels involved. Hence a call to ``stack`` and then ``unstack``, or viceversa,
156165
will result in a **sorted** copy of the original DataFrame or Series:
@@ -165,15 +174,6 @@ will result in a **sorted** copy of the original DataFrame or Series:
165174
while the above code will raise a ``TypeError`` if the call to ``sort`` is
166175
removed.
167176

168-
.. _reshaping.unstack_by_name:
169-
170-
If the indexes have names, you can use the level names instead of specifying
171-
the level numbers:
172-
173-
.. ipython:: python
174-
175-
stacked.unstack('second')
176-
177177
.. _reshaping.stack_multiple:
178178

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

0 commit comments

Comments
 (0)