Skip to content

DOC: fix an example which raised a KeyError in v0.11.0.rst #54683

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 22, 2023
Merged
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
26 changes: 19 additions & 7 deletions doc/source/whatsnew/v0.11.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,27 @@ Enhancements

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

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

idx = pd.date_range("2001-10-1", periods=5, freq='M')
ts = pd.Series(np.random.rand(len(idx)), index=idx)
ts['2001']
In [30]: idx = pd.date_range("2001-10-1", periods=5, freq='M')

df = pd.DataFrame({'A': ts})
df['2001']
In [31]: ts = pd.Series(np.random.rand(len(idx)), index=idx)

In [32]: ts['2001']
Out[32]:
2001-10-31 0.117967
2001-11-30 0.702184
2001-12-31 0.414034
Freq: M, dtype: float64

In [33]: df = pd.DataFrame({'A': ts})

In [34]: df['2001']
Out[34]:
A
2001-10-31 0.117967
2001-11-30 0.702184
2001-12-31 0.414034

- ``Squeeze`` to possibly remove length 1 dimensions from an object.

Expand Down