@@ -5,11 +5,6 @@ v0.10.1 (January 22, 2013)
5
5
6
6
{{ header }}
7
7
8
- .. ipython :: python
9
- :suppress:
10
-
11
- from pandas import * # noqa F401, F403
12
-
13
8
14
9
This is a minor release from 0.10.0 and includes new features, enhancements,
15
10
and bug fixes. In particular, there is substantial new HDFStore functionality
@@ -48,24 +43,27 @@ You may need to upgrade your existing data files. Please visit the
48
43
:suppress:
49
44
:okexcept:
50
45
46
+ import os
47
+
51
48
os.remove(' store.h5' )
52
49
53
50
You can designate (and index) certain columns that you want to be able to
54
51
perform queries on a table, by passing a list to ``data_columns ``
55
52
56
53
.. ipython :: python
57
54
58
- store = HDFStore(' store.h5' )
59
- df = DataFrame(randn(8 , 3 ), index = date_range(' 1/1/2000' , periods = 8 ),
60
- columns = [' A' , ' B' , ' C' ])
55
+ store = pd.HDFStore(' store.h5' )
56
+ df = pd.DataFrame(np.random.randn(8 , 3 ),
57
+ index = pd.date_range(' 1/1/2000' , periods = 8 ),
58
+ columns = [' A' , ' B' , ' C' ])
61
59
df[' string' ] = ' foo'
62
60
df.loc[df.index[4 :6 ], ' string' ] = np.nan
63
61
df.loc[df.index[7 :9 ], ' string' ] = ' bar'
64
62
df[' string2' ] = ' cool'
65
63
df
66
64
67
65
# on-disk operations
68
- store.append(' df' , df, data_columns = [' B' ,' C' ,' string' ,' string2' ])
66
+ store.append(' df' , df, data_columns = [' B' , ' C' , ' string' , ' string2' ])
69
67
store.select(' df' , " B>0 and string=='foo'" )
70
68
71
69
# this is in-memory version of this type of selection
@@ -77,16 +75,16 @@ Retrieving unique values in an indexable or data column.
77
75
78
76
# note that this is deprecated as of 0.14.0
79
77
# can be replicated by: store.select_column('df','index').unique()
80
- store.unique(' df' ,' index' )
81
- store.unique(' df' ,' string' )
78
+ store.unique(' df' , ' index' )
79
+ store.unique(' df' , ' string' )
82
80
83
81
You can now store ``datetime64 `` in data columns
84
82
85
83
.. ipython :: python
86
84
87
- df_mixed = df.copy()
88
- df_mixed[' datetime64' ] = Timestamp(' 20010102' )
89
- df_mixed.loc[df_mixed.index[3 :4 ], [' A' ,' B' ]] = np.nan
85
+ df_mixed = df.copy()
86
+ df_mixed[' datetime64' ] = pd. Timestamp(' 20010102' )
87
+ df_mixed.loc[df_mixed.index[3 :4 ], [' A' , ' B' ]] = np.nan
90
88
91
89
store.append(' df_mixed' , df_mixed)
92
90
df_mixed1 = store.select(' df_mixed' )
@@ -99,21 +97,21 @@ columns, this is equivalent to passing a
99
97
100
98
.. ipython :: python
101
99
102
- store.select(' df' ,columns = [' A' ,' B' ])
100
+ store.select(' df' , columns = [' A' , ' B' ])
103
101
104
102
``HDFStore `` now serializes MultiIndex dataframes when appending tables.
105
103
106
104
.. code-block :: ipython
107
105
108
- In [19]: index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'],
109
- ....: ['one', 'two', 'three']],
110
- ....: labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3],
111
- ....: [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
112
- ....: names=['foo', 'bar'])
106
+ In [19]: index = pd. MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'],
107
+ ....: ['one', 'two', 'three']],
108
+ ....: labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3],
109
+ ....: [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
110
+ ....: names=['foo', 'bar'])
113
111
....:
114
112
115
- In [20]: df = DataFrame(np.random.randn(10, 3), index=index,
116
- ....: columns=['A', 'B', 'C'])
113
+ In [20]: df = pd. DataFrame(np.random.randn(10, 3), index=index,
114
+ ....: columns=['A', 'B', 'C'])
117
115
....:
118
116
119
117
In [21]: df
@@ -131,7 +129,7 @@ columns, this is equivalent to passing a
131
129
two -3.207595 -1.535854 0.409769
132
130
three -0.673145 -0.741113 -0.110891
133
131
134
- In [22]: store.append('mi',df)
132
+ In [22]: store.append('mi', df)
135
133
136
134
In [23]: store.select('mi')
137
135
Out[23]:
@@ -162,26 +160,28 @@ combined result, by using ``where`` on a selector table.
162
160
163
161
.. ipython :: python
164
162
165
- df_mt = DataFrame(randn(8 , 6 ), index = date_range(' 1/1/2000' , periods = 8 ),
166
- columns = [' A' , ' B' , ' C' , ' D' , ' E' , ' F' ])
163
+ df_mt = pd.DataFrame(np.random.randn(8 , 6 ),
164
+ index = pd.date_range(' 1/1/2000' , periods = 8 ),
165
+ columns = [' A' , ' B' , ' C' , ' D' , ' E' , ' F' ])
167
166
df_mt[' foo' ] = ' bar'
168
167
169
168
# you can also create the tables individually
170
- store.append_to_multiple({ ' df1_mt' : [' A' ,' B' ], ' df2_mt' : None }, df_mt, selector = ' df1_mt' )
169
+ store.append_to_multiple({' df1_mt' : [' A' , ' B' ], ' df2_mt' : None },
170
+ df_mt, selector = ' df1_mt' )
171
171
store
172
172
173
173
# indiviual tables were created
174
174
store.select(' df1_mt' )
175
175
store.select(' df2_mt' )
176
176
177
177
# as a multiple
178
- store.select_as_multiple([' df1_mt' ,' df2_mt' ], where = [ ' A>0' ,' B>0' ], selector = ' df1_mt' )
178
+ store.select_as_multiple([' df1_mt' , ' df2_mt' ], where = [' A>0' , ' B>0' ],
179
+ selector = ' df1_mt' )
179
180
180
181
.. ipython :: python
181
182
:suppress:
182
183
183
184
store.close()
184
- import os
185
185
os.remove(' store.h5' )
186
186
187
187
**Enhancements **
0 commit comments