Skip to content

Commit 8afb742

Browse files
authored
DOC: freeze old whatsnew notes part 1 #6856 (#41464)
1 parent 0c7b728 commit 8afb742

File tree

4 files changed

+160
-53
lines changed

4 files changed

+160
-53
lines changed

doc/source/whatsnew/v0.5.0.rst

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ Version 0.5.0 (October 24, 2011)
66

77
{{ header }}
88

9-
.. ipython:: python
10-
:suppress:
11-
12-
from pandas import * # noqa F401, F403
13-
14-
159
New features
1610
~~~~~~~~~~~~
1711

doc/source/whatsnew/v0.6.0.rst

-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ Version 0.6.0 (November 25, 2011)
55

66
{{ header }}
77

8-
.. ipython:: python
9-
:suppress:
10-
11-
from pandas import * # noqa F401, F403
12-
13-
148
New features
159
~~~~~~~~~~~~
1610
- :ref:`Added <reshaping.melt>` ``melt`` function to ``pandas.core.reshape``

doc/source/whatsnew/v0.7.0.rst

+92-19
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,22 @@ New features
3131

3232
- Handle differently-indexed output values in ``DataFrame.apply`` (:issue:`498`)
3333

34-
.. ipython:: python
34+
.. code-block:: ipython
3535
36-
df = pd.DataFrame(np.random.randn(10, 4))
37-
df.apply(lambda x: x.describe())
36+
In [1]: df = pd.DataFrame(np.random.randn(10, 4))
37+
In [2]: df.apply(lambda x: x.describe())
38+
Out[2]:
39+
0 1 2 3
40+
count 10.000000 10.000000 10.000000 10.000000
41+
mean 0.190912 -0.395125 -0.731920 -0.403130
42+
std 0.730951 0.813266 1.112016 0.961912
43+
min -0.861849 -2.104569 -1.776904 -1.469388
44+
25% -0.411391 -0.698728 -1.501401 -1.076610
45+
50% 0.380863 -0.228039 -1.191943 -1.004091
46+
75% 0.658444 0.057974 -0.034326 0.461706
47+
max 1.212112 0.577046 1.643563 1.071804
48+
49+
[8 rows x 4 columns]
3850
3951
- :ref:`Add<advanced.reorderlevels>` ``reorder_levels`` method to Series and
4052
DataFrame (:issue:`534`)
@@ -116,13 +128,31 @@ One of the potentially riskiest API changes in 0.7.0, but also one of the most
116128
important, was a complete review of how **integer indexes** are handled with
117129
regard to label-based indexing. Here is an example:
118130

119-
.. ipython:: python
131+
.. code-block:: ipython
120132
121-
s = pd.Series(np.random.randn(10), index=range(0, 20, 2))
122-
s
123-
s[0]
124-
s[2]
125-
s[4]
133+
In [3]: s = pd.Series(np.random.randn(10), index=range(0, 20, 2))
134+
In [4]: s
135+
Out[4]:
136+
0 -1.294524
137+
2 0.413738
138+
4 0.276662
139+
6 -0.472035
140+
8 -0.013960
141+
10 -0.362543
142+
12 -0.006154
143+
14 -0.923061
144+
16 0.895717
145+
18 0.805244
146+
Length: 10, dtype: float64
147+
148+
In [5]: s[0]
149+
Out[5]: -1.2945235902555294
150+
151+
In [6]: s[2]
152+
Out[6]: 0.41373810535784006
153+
154+
In [7]: s[4]
155+
Out[7]: 0.2766617129497566
126156
127157
This is all exactly identical to the behavior before. However, if you ask for a
128158
key **not** contained in the Series, in versions 0.6.1 and prior, Series would
@@ -235,22 +265,65 @@ slice to a Series when getting and setting values via ``[]`` (i.e. the
235265
``__getitem__`` and ``__setitem__`` methods). The behavior will be the same as
236266
passing similar input to ``ix`` **except in the case of integer indexing**:
237267

238-
.. ipython:: python
268+
.. code-block:: ipython
239269
240-
s = pd.Series(np.random.randn(6), index=list('acegkm'))
241-
s
242-
s[['m', 'a', 'c', 'e']]
243-
s['b':'l']
244-
s['c':'k']
270+
In [8]: s = pd.Series(np.random.randn(6), index=list('acegkm'))
271+
272+
In [9]: s
273+
Out[9]:
274+
a -1.206412
275+
c 2.565646
276+
e 1.431256
277+
g 1.340309
278+
k -1.170299
279+
m -0.226169
280+
Length: 6, dtype: float64
281+
282+
In [10]: s[['m', 'a', 'c', 'e']]
283+
Out[10]:
284+
m -0.226169
285+
a -1.206412
286+
c 2.565646
287+
e 1.431256
288+
Length: 4, dtype: float64
289+
290+
In [11]: s['b':'l']
291+
Out[11]:
292+
c 2.565646
293+
e 1.431256
294+
g 1.340309
295+
k -1.170299
296+
Length: 4, dtype: float64
297+
298+
In [12]: s['c':'k']
299+
Out[12]:
300+
c 2.565646
301+
e 1.431256
302+
g 1.340309
303+
k -1.170299
304+
Length: 4, dtype: float64
245305
246306
In the case of integer indexes, the behavior will be exactly as before
247307
(shadowing ``ndarray``):
248308

249-
.. ipython:: python
309+
.. code-block:: ipython
250310
251-
s = pd.Series(np.random.randn(6), index=range(0, 12, 2))
252-
s[[4, 0, 2]]
253-
s[1:5]
311+
In [13]: s = pd.Series(np.random.randn(6), index=range(0, 12, 2))
312+
313+
In [14]: s[[4, 0, 2]]
314+
Out[14]:
315+
4 0.132003
316+
0 0.410835
317+
2 0.813850
318+
Length: 3, dtype: float64
319+
320+
In [15]: s[1:5]
321+
Out[15]:
322+
2 0.813850
323+
4 0.132003
324+
6 -0.827317
325+
8 -0.076467
326+
Length: 4, dtype: float64
254327
255328
If you wish to do indexing with sequences and slicing on an integer index with
256329
label semantics, use ``ix``.

doc/source/whatsnew/v0.7.3.rst

+68-22
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,37 @@ NA boolean comparison API change
5151
Reverted some changes to how NA values (represented typically as ``NaN`` or
5252
``None``) are handled in non-numeric Series:
5353

54-
.. ipython:: python
54+
.. code-block:: ipython
5555
56-
series = pd.Series(["Steve", np.nan, "Joe"])
57-
series == "Steve"
58-
series != "Steve"
56+
In [1]: series = pd.Series(["Steve", np.nan, "Joe"])
57+
58+
In [2]: series == "Steve"
59+
Out[2]:
60+
0 True
61+
1 False
62+
2 False
63+
Length: 3, dtype: bool
64+
65+
In [3]: series != "Steve"
66+
Out[3]:
67+
0 False
68+
1 True
69+
2 True
70+
Length: 3, dtype: bool
5971
6072
In comparisons, NA / NaN will always come through as ``False`` except with
6173
``!=`` which is ``True``. *Be very careful* with boolean arithmetic, especially
6274
negation, in the presence of NA data. You may wish to add an explicit NA
6375
filter into boolean array operations if you are worried about this:
6476

65-
.. ipython:: python
77+
.. code-block:: ipython
78+
79+
In [4]: mask = series == "Steve"
6680
67-
mask = series == "Steve"
68-
series[mask & series.notnull()]
81+
In [5]: series[mask & series.notnull()]
82+
Out[5]:
83+
0 Steve
84+
Length: 1, dtype: object
6985
7086
While propagating NA in comparisons may seem like the right behavior to some
7187
users (and you could argue on purely technical grounds that this is the right
@@ -80,21 +96,51 @@ Other API changes
8096
When calling ``apply`` on a grouped Series, the return value will also be a
8197
Series, to be more consistent with the ``groupby`` behavior with DataFrame:
8298

83-
.. ipython:: python
84-
:okwarning:
85-
86-
df = pd.DataFrame(
87-
{
88-
"A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
89-
"B": ["one", "one", "two", "three", "two", "two", "one", "three"],
90-
"C": np.random.randn(8),
91-
"D": np.random.randn(8),
92-
}
93-
)
94-
df
95-
grouped = df.groupby("A")["C"]
96-
grouped.describe()
97-
grouped.apply(lambda x: x.sort_values()[-2:]) # top 2 values
99+
.. code-block:: ipython
100+
101+
In [6]: df = pd.DataFrame(
102+
...: {
103+
...: "A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
104+
...: "B": ["one", "one", "two", "three", "two", "two", "one", "three"],
105+
...: "C": np.random.randn(8),
106+
...: "D": np.random.randn(8),
107+
...: }
108+
...: )
109+
...:
110+
111+
In [7]: df
112+
Out[7]:
113+
A B C D
114+
0 foo one 0.469112 -0.861849
115+
1 bar one -0.282863 -2.104569
116+
2 foo two -1.509059 -0.494929
117+
3 bar three -1.135632 1.071804
118+
4 foo two 1.212112 0.721555
119+
5 bar two -0.173215 -0.706771
120+
6 foo one 0.119209 -1.039575
121+
7 foo three -1.044236 0.271860
122+
123+
[8 rows x 4 columns]
124+
125+
In [8]: grouped = df.groupby("A")["C"]
126+
127+
In [9]: grouped.describe()
128+
Out[9]:
129+
count mean std min 25% 50% 75% max
130+
A
131+
bar 3.0 -0.530570 0.526860 -1.135632 -0.709248 -0.282863 -0.228039 -0.173215
132+
foo 5.0 -0.150572 1.113308 -1.509059 -1.044236 0.119209 0.469112 1.212112
133+
134+
[2 rows x 8 columns]
135+
136+
In [10]: grouped.apply(lambda x: x.sort_values()[-2:]) # top 2 values
137+
Out[10]:
138+
A
139+
bar 1 -0.282863
140+
5 -0.173215
141+
foo 0 0.469112
142+
4 1.212112
143+
Name: C, Length: 4, dtype: float64
98144
99145
100146
.. _whatsnew_0.7.3.contributors:

0 commit comments

Comments
 (0)