Version 0.10.1 (January 22, 2013)
DatetimeIndex.unique now returns a DatetimeIndex with the same name and
timezone instead of an array (GH 2563)
np
.
nan
store
.
append
(
"df_mixed"
,
df_mixed
)
df_mixed1
=
store
.
select
(
"df_mixed"
)
df_mixed1
Out[16]:
A B ... string2 datetime64
2000-01-01 0.469112 -0.282863 ... cool 1970-01-01 00:00:00.978393600
2000-01-02 -1.135632 1.212112 ... cool 1970-01-01 00:00:00.978393600
2000-01-03 0.119209 -1.044236 ... cool 1970-01-01 00:00:00.978393600
2000-01-04 NaN NaN ... cool 1970-01-01 00:00:00.978393600
2000-01-05 0.721555 -0.706771 ... cool 1970-01-01 00:00:00.978393600
2000-01-06 0.271860 -0.424972 ... cool 1970-01-01 00:00:00.978393600
2000-01-07 0.276232 -1.087401 ... cool 1970-01-01 00:00:00.978393600
2000-01-08 0.113648 -1.478427 ... cool 1970-01-01 00:00:00.978393600
[8 rows x 6 columns]
df_mixed1
.
dtypes
.
value_counts
()
Out[17]:
float64 3
object 2
datetime64[ns] 1
Name: count, dtype: int64
,
1
,
2
,
2
,
3
,
3
,
3
],
[
0
,
1
,
2
,
0
,
1
,
1
,
2
,
0
,
1
,
2
]],
names
=
[
'foo'
,
'bar'
])
df
=
pd
.
DataFrame
(
np
.
random
.
randn
(
10
,
3
),
index
=
index
,
columns
=
[
'A'
,
'B'
,
'C'
])
df
Out[21]:
A B C
foo bar
foo one -0.116619 0.295575 -1.047704
two 1.640556 1.905836 2.772115
three 0.088787 -1.144197 -0.633372
bar one 0.925372 -0.006438 -0.820408
two -0.600874 -1.039266 0.824758
baz two -0.824095 -0.337730 -0.927764
three -0.840123 0.248505 -0.109250
qux one 0.431977 -0.460710 0.336505
two -3.207595 -1.535854 0.409769
three -0.673145 -0.741113 -0.110891
store
.
append
(
'mi'
,
df
)
store
.
select
(
'mi'
)
Out[23]:
A B C
foo bar
foo one -0.116619 0.295575 -1.047704
two 1.640556 1.905836 2.772115
three 0.088787 -1.144197 -0.633372
bar one 0.925372 -0.006438 -0.820408
two -0.600874 -1.039266 0.824758
baz two -0.824095 -0.337730 -0.927764
three -0.840123 0.248505 -0.109250
qux one 0.431977 -0.460710 0.336505
two -3.207595 -1.535854 0.409769
three -0.673145 -0.741113 -0.110891
# the levels are automatically included as data columns
store
.
select
(
'mi'
,
"foo='bar'"
)
Out[24]:
A B C
foo bar
bar one 0.925372 -0.006438 -0.820408
two -0.600874 -1.039266 0.824758
"B"
,
"C"
,
"D"
,
"E"
,
"F"
],
)
df_mt
[
"foo"
]
=
"bar"
# you can also create the tables individually
store
.
append_to_multiple
(
{
"df1_mt"
:
[
"A"
,
"B"
],
"df2_mt"
:
None
},
df_mt
,
selector
=
"df1_mt"
)
store
Out[22]:
<class 'pandas.io.pytables.HDFStore'>
File path: store.h5
# individual tables were created
store
.
select
(
"df1_mt"
)
Out[23]:
A B
2000-01-01 0.404705 0.577046
2000-01-02 -1.344312 0.844885
2000-01-03 0.357021 -0.674600
2000-01-04 0.276662 -0.472035
2000-01-05 0.895717 0.805244
2000-01-06 -1.170299 -0.226169
2000-01-07 -0.076467 -1.187678
2000-01-08 1.024180 0.569605
store
.
select
(
"df2_mt"
)
Out[24]:
C D E F foo
2000-01-01 -1.715002 -1.039268 -0.370647 -1.157892 bar
2000-01-02 1.075770 -0.109050 1.643563 -1.469388 bar
2000-01-03 -1.776904 -0.968914 -1.294524 0.413738 bar
2000-01-04 -0.013960 -0.362543 -0.006154 -0.923061 bar
2000-01-05 -1.206412 2.565646 1.431256 1.340309 bar
2000-01-06 0.410835 0.813850 0.132003 -0.827317 bar
2000-01-07 1.130127 -1.436737 -1.413681 1.607920 bar
2000-01-08 0.875906 -2.211372 0.974466 -2.006747 bar
# as a multiple
store
.
select_as_multiple
(
[
"df1_mt"
,
"df2_mt"
],
where
=
[
"A>0"
,
"B>0"
],
selector
=
"df1_mt"
)
Out[25]:
A B C D E F foo
2000-01-01 0.404705 0.577046 -1.715002 -1.039268 -0.370647 -1.157892 bar
2000-01-05 0.895717 0.805244 -1.206412 2.565646 1.431256 1.340309 bar
2000-01-08 1.024180 0.569605 0.875906 -2.211372 0.974466 -2.006747 bar
You can pass expectedrows=an integer to the first append, to set the
TOTAL number of expected rows that PyTables will expected. This will
optimize read/write performance.
Select now supports passing start and stop to provide selection
space limiting in selection.
Greatly improved ISO8601 (e.g., yyyy-mm-dd) date parsing for file parsers (GH 2698)
Allow DataFrame.merge to handle combinatorial sizes too large for 64-bit
integer (GH 2690)
Series now has unary negation (-series) and inversion (~series) operators (GH 2686)
DataFrame.plot now includes a logx parameter to change the x-axis to log scale (GH 2327)
Series arithmetic operators can now handle constant and ndarray input (GH 2574)
ExcelFile now takes a kind argument to specify the file type (GH 2613)
A faster implementation for Series.str methods (GH 2602)
Fixed performance issues while aggregating boolean data (GH 2692)
When given a boolean mask key and a Series of new values, Series __setitem__
will now align the incoming values with the original Series (GH 2686)
Fixed MemoryError caused by performing counting sort on sorting MultiIndex
levels with a very large number of combinatorial values (GH 2684)
Fixed bug that causes plotting to fail when the index is a DatetimeIndex with
a fixed-offset timezone (GH 2683)
Corrected business day subtraction logic when the offset is more than 5 bdays
and the starting date is on a weekend (GH 2680)
Fixed C file parser behavior when the file has more columns than data
(GH 2668)
Fixed file reader bug that misaligned columns with data in the presence of an
implicit column and a specified usecols value
DataFrames with numerical or datetime indices are now sorted prior to
plotting (GH 2609)
Fixed DataFrame.from_records error when passed columns, index, but empty
records (GH 2633)