@@ -5,10 +5,6 @@ v0.13.1 (February 3, 2014)
5
5
6
6
{{ header }}
7
7
8
- .. ipython :: python
9
- :suppress:
10
-
11
- from pandas import * # noqa F401, F403
12
8
13
9
14
10
This is a minor release from 0.13.0 and includes a small number of API changes, several new features,
@@ -35,16 +31,16 @@ Highlights include:
35
31
36
32
.. ipython :: python
37
33
38
- df = DataFrame(dict ( A = np.array([' foo' ,' bar' ,' bah' ,' foo' ,' bar' ])) )
34
+ df = pd. DataFrame({ ' A ' : np.array([' foo' , ' bar' , ' bah' , ' foo' , ' bar' ])} )
39
35
df[' A' ].iloc[0 ] = np.nan
40
36
df
41
37
42
38
The recommended way to do this type of assignment is:
43
39
44
40
.. ipython :: python
45
41
46
- df = DataFrame(dict ( A = np.array([' foo' ,' bar' ,' bah' ,' foo' ,' bar' ])) )
47
- df.loc[0 ,' A' ] = np.nan
42
+ df = pd. DataFrame({ ' A ' : np.array([' foo' , ' bar' , ' bah' , ' foo' , ' bar' ])} )
43
+ df.loc[0 , ' A' ] = np.nan
48
44
df
49
45
50
46
Output Formatting Enhancements
@@ -58,28 +54,29 @@ Output Formatting Enhancements
58
54
59
55
max_info_rows = pd.get_option(' max_info_rows' )
60
56
61
- df = DataFrame(dict (A = np.random.randn(10 ),
62
- B = np.random.randn(10 ),
63
- C = date_range(' 20130101' ,periods = 10 )))
64
- df.iloc[3 :6 ,[0 ,2 ]] = np.nan
57
+ df = pd.DataFrame({' A' : np.random.randn(10 ),
58
+ ' B' : np.random.randn(10 ),
59
+ ' C' : pd.date_range(' 20130101' , periods = 10 )
60
+ })
61
+ df.iloc[3 :6 , [0 , 2 ]] = np.nan
65
62
66
63
.. ipython :: python
67
64
68
65
# set to not display the null counts
69
- pd.set_option(' max_info_rows' ,0 )
66
+ pd.set_option(' max_info_rows' , 0 )
70
67
df.info()
71
68
72
69
.. ipython :: python
73
70
74
71
# this is the default (same as in 0.13.0)
75
- pd.set_option(' max_info_rows' ,max_info_rows)
72
+ pd.set_option(' max_info_rows' , max_info_rows)
76
73
df.info()
77
74
78
75
- Add ``show_dimensions `` display option for the new DataFrame repr to control whether the dimensions print.
79
76
80
77
.. ipython :: python
81
78
82
- df = DataFrame([[1 , 2 ], [3 , 4 ]])
79
+ df = pd. DataFrame([[1 , 2 ], [3 , 4 ]])
83
80
pd.set_option(' show_dimensions' , False )
84
81
df
85
82
@@ -89,10 +86,13 @@ Output Formatting Enhancements
89
86
- The ``ArrayFormatter `` for ``datetime `` and ``timedelta64 `` now intelligently
90
87
limit precision based on the values in the array (:issue: `3401 `)
91
88
92
- Previously output might look like:
93
-
94
- .. code-block :: python
89
+ Previously output might look like:::
95
90
91
+ >>> df = pd.DataFrame([pd.Timestamp('20010101'),
92
+ pd.Timestamp('20040601')], columns=['age'])
93
+ >>> df['today'] = pd.Timestamp('20130419')
94
+ >>> df['diff'] = df['today'] - df['age']
95
+ >>> df
96
96
age today diff
97
97
0 2001-01-01 00:00:00 2013-04-19 00:00:00 4491 days, 00:00:00
98
98
1 2004-06-01 00:00:00 2013-04-19 00:00:00 3244 days, 00:00:00
@@ -101,10 +101,10 @@ Output Formatting Enhancements
101
101
102
102
.. ipython :: python
103
103
104
- df = DataFrame([ Timestamp(' 20010101' ),
105
- Timestamp(' 20040601' ) ], columns = [' age' ])
106
- df[' today' ] = Timestamp(' 20130419' )
107
- df[' diff' ] = df[' today' ]- df[' age' ]
104
+ df = pd. DataFrame([pd. Timestamp(' 20010101' ),
105
+ pd. Timestamp(' 20040601' )], columns = [' age' ])
106
+ df[' today' ] = pd. Timestamp(' 20130419' )
107
+ df[' diff' ] = df[' today' ] - df[' age' ]
108
108
df
109
109
110
110
API changes
@@ -118,7 +118,7 @@ API changes
118
118
119
119
.. ipython :: python
120
120
121
- s = Series([' a' , ' a|b' , np.nan, ' a|c' ])
121
+ s = pd. Series([' a' , ' a|b' , np.nan, ' a|c' ])
122
122
s.str.get_dummies(sep = ' |' )
123
123
124
124
- Added the ``NDFrame.equals() `` method to compare if two NDFrames are
@@ -129,8 +129,8 @@ API changes
129
129
130
130
.. code-block :: python
131
131
132
- df = DataFrame({' col' :[' foo' , 0 , np.nan]})
133
- df2 = DataFrame({' col' :[np.nan, 0 , ' foo' ]}, index = [2 ,1 , 0 ])
132
+ df = pd. DataFrame({' col' : [' foo' , 0 , np.nan]})
133
+ df2 = pd. DataFrame({' col' : [np.nan, 0 , ' foo' ]}, index = [2 , 1 , 0 ])
134
134
df.equals(df2)
135
135
df.equals(df2.sort_index())
136
136
@@ -221,7 +221,7 @@ Enhancements
221
221
shades = [' light' , ' dark' ]
222
222
colors = [' red' , ' green' , ' blue' ]
223
223
224
- MultiIndex.from_product([shades, colors], names = [' shade' , ' color' ])
224
+ pd. MultiIndex.from_product([shades, colors], names = [' shade' , ' color' ])
225
225
226
226
- Panel :meth: `~pandas.Panel.apply ` will work on non-ufuncs. See :ref: `the docs<basics.apply_panel> `.
227
227
@@ -255,30 +255,30 @@ Enhancements
255
255
256
256
.. ipython :: python
257
257
258
- result = panel.apply(
259
- lambda x : (x- x.mean())/ x.std(),
260
- axis = ' major_axis' )
258
+ result = panel.apply(lambda x : (x - x.mean()) / x.std(),
259
+ axis = ' major_axis' )
261
260
result
262
261
result[' ItemA' ]
263
262
264
263
- Panel :meth: `~pandas.Panel.apply ` operating on cross-sectional slabs. (:issue: `1148 `)
265
264
266
265
.. ipython :: python
267
266
268
- f = lambda x : ((x.T- x.mean(1 ))/ x.std(1 )).T
267
+ def f (x ):
268
+ return ((x.T - x.mean(1 )) / x.std(1 )).T
269
269
270
- result = panel.apply(f, axis = [' items' ,' major_axis' ])
270
+ result = panel.apply(f, axis = [' items' , ' major_axis' ])
271
271
result
272
- result.loc[:,:, ' ItemA' ]
272
+ result.loc[:, :, ' ItemA' ]
273
273
274
274
This is equivalent to the following
275
275
276
276
.. ipython :: python
277
277
278
- result = Panel(dict ([ (ax, f(panel.loc[:,:, ax]))
279
- for ax in panel.minor_axis ]))
278
+ result = pd. Panel({ax: f(panel.loc[:, :, ax]) for ax in panel.minor_axis} )
279
+
280
280
result
281
- result.loc[:,:, ' ItemA' ]
281
+ result.loc[:, :, ' ItemA' ]
282
282
283
283
Performance
284
284
~~~~~~~~~~~
0 commit comments