Skip to content

Commit f5a8cce

Browse files
authored
DOC: fix an example which raised a KeyError in v0.11.0.rst (#54683)
fix example in whatsnew/v0.11.0.rst
1 parent 43691a2 commit f5a8cce

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

doc/source/whatsnew/v0.11.0.rst

+19-7
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,27 @@ Enhancements
367367

368368
- You can now select with a string from a DataFrame with a datelike index, in a similar way to a Series (:issue:`3070`)
369369

370-
.. ipython:: python
371-
:okexcept:
370+
.. code-block:: ipython
372371
373-
idx = pd.date_range("2001-10-1", periods=5, freq='M')
374-
ts = pd.Series(np.random.rand(len(idx)), index=idx)
375-
ts['2001']
372+
In [30]: idx = pd.date_range("2001-10-1", periods=5, freq='M')
376373
377-
df = pd.DataFrame({'A': ts})
378-
df['2001']
374+
In [31]: ts = pd.Series(np.random.rand(len(idx)), index=idx)
375+
376+
In [32]: ts['2001']
377+
Out[32]:
378+
2001-10-31 0.117967
379+
2001-11-30 0.702184
380+
2001-12-31 0.414034
381+
Freq: M, dtype: float64
382+
383+
In [33]: df = pd.DataFrame({'A': ts})
384+
385+
In [34]: df['2001']
386+
Out[34]:
387+
A
388+
2001-10-31 0.117967
389+
2001-11-30 0.702184
390+
2001-12-31 0.414034
379391
380392
- ``Squeeze`` to possibly remove length 1 dimensions from an object.
381393

0 commit comments

Comments
 (0)