Skip to content

Commit

Permalink
include before/after examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRobo committed Feb 19, 2020
1 parent 2728408 commit c29c2bd
Showing 1 changed file with 54 additions and 10 deletions.
64 changes: 54 additions & 10 deletions doc/source/whatsnew/v1.1.0.rst
Expand Up @@ -188,17 +188,61 @@ MultiIndex
left.intersection(right, sort=False)
- Bug in :meth:`MultiIndex.get_indexer` incorrectly handling use of pad and backfill options (:issue:`29896`)
.. ipython:: python
df = pd.DataFrame({
'a': [0, 0, 0, 0],
'b': [0, 2, 3, 4],
'c': ['A', 'B', 'C', 'D']
}).set_index(['a', 'b'])
mi_2 = pd.MultiIndex.from_product([[0], [-1, 0, 1, 3, 4, 5]])
*pandas [0.23.0, 1.1.0)*
.. code-block:: python
>>> df = pd.DataFrame({
... 'a': [0, 0, 0, 0],
... 'b': [0, 2, 3, 4],
... 'c': ['A', 'B', 'C', 'D'],
... }).set_index(['a', 'b'])
>>> mi_2 = pd.MultiIndex.from_product([[0], [-1, 0, 1, 3, 4, 5]])
>>>
>>> df.reindex(mi_2, method="backfill")
c
0 -1 A
0 A
1 D
3 A
4 A
5 C
>>>
>>> df.reindex(mi_2, method="pad")
c
0 -1 NaN
0 NaN
1 D
3 NaN
4 A
5 C
*pandas 1.1.0*:
.. code-block:: python
>>> df = pd.DataFrame({
... 'a': [0, 0, 0, 0],
... 'b': [0, 2, 3, 4],
... 'c': ['A', 'B', 'C', 'D'],
... }).set_index(['a', 'b'])
>>> mi_2 = pd.MultiIndex.from_product([[0], [-1, 0, 1, 3, 4, 5]])
>>>
>>> df.reindex(mi_2, method="backfill")
c
0 -1 A
0 A
1 B
3 C
4 D
5 NaN
>>>
>>> df.reindex(mi_2, method="pad")
c
0 -1 NaN
0 A
1 A
3 C
4 D
5 D
>>>
df.reindex(mi_2, method='backfill')
df.reindex(mi_2, method='pad')
-

I/O
Expand Down

0 comments on commit c29c2bd

Please sign in to comment.