Skip to content

Commit 95a06d6

Browse files
committed
Support HDFStore
1 parent 377e29b commit 95a06d6

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ before_install:
1717
- sudo pip3 install numpy
1818
- sudo pip3 install Cython
1919
- sudo pip3 install pandas
20+
- sudo pip3 install tables

src/Pandas.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import Base: getindex, setindex!, length, size, show, merge, convert,
1111
join, replace, lastindex, sum, abs, any, count,
1212
cumprod, cumsum, diff, filter, first, last,
1313
min, sort, truncate, +, -, *, /, !,
14-
==, >, <, >=, <=, !=, &, |
14+
==, >, <, >=, <=, !=, &, |,
15+
keys, close, get
1516
import Statistics: mean, std, var, cov, median, quantile
1617

1718

@@ -219,6 +220,7 @@ end
219220
@pytype GroupBy ()->pandas_raw.core.groupby."DataFrameGroupBy"
220221
@pytype SeriesGroupBy ()->pandas_raw.core.groupby."SeriesGroupBy"
221222
@pytype Rolling () -> pandas_raw.core.window."Rolling"
223+
@pytype HDFStore () -> pandas_raw.io.pytables.HDFStore
222224

223225
@pyattr GroupBy app apply
224226
@pyattr Rolling app apply
@@ -245,6 +247,7 @@ pyattr_set([DataFrame, Series], :T, :abs, :align, :any, :argsort, :asfreq, :asof
245247
:xs, :merge)
246248
pyattr_set([DataFrame], :groupby)
247249
pyattr_set([Series, DataFrame], :rolling)
250+
pyattr_set([HDFStore], :put, :append, :get, :select, :info, :keys, :groups, :walk, :close)
248251

249252
Base.size(x::Union{Loc, Iloc, Ix}) = x.pyo.obj.shape
250253
Base.size(df::PandasWrapped, i::Integer) = size(df)[i]
@@ -279,6 +282,7 @@ end
279282
@pyasvec Index
280283
@pyasvec GroupBy
281284
@pyasvec Rolling
285+
@pyasvec HDFStore
282286

283287
Base.ndims(df::Union{DataFrame, Series}) = length(size(df))
284288

@@ -293,7 +297,7 @@ for m in [:read_pickle, :read_csv, :read_html, :read_json, :read_excel, :read_ta
293297
:rolling_cov, :expanding_cov, :rolling_skew, :expanding_skew, :rolling_kurt,
294298
:expanding_kurt, :rolling_apply, :expanding_apply, :rolling_quantile,
295299
:expanding_quantile, :rolling_window, :to_numeric, :read_sql, :read_sql_table,
296-
:read_sql_query]
300+
:read_sql_query, :read_hdf]
297301
@eval begin
298302
function $m(args...; kwargs...)
299303
method = pandas_raw.$(string(m))

src/exports.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ tz_localize,
192192
unstack,
193193
var,
194194
weekday,
195-
read_sql
195+
read_sql,
196+
read_hdf,
197+
HDFStore,
198+
info,
199+
put,
200+
walk
196201

197202
if !isdefined(Base, :drop)
198203
export drop

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ x = Series([3,5], index=[:a, :b])
3535
# Rolling
3636
roll = rolling(Series([1,2,3,4,5]), 3)
3737
@test isequal(values(mean(roll)), [NaN, NaN, 2.0, 3.0, 4.0])
38+
39+
# HDF
40+
mktempdir() do dir
41+
store = HDFStore("$(dir)/store.h5")
42+
x = Series(["a", "b"])
43+
store["x"] = x
44+
x_fromstore = store["x"]
45+
@test values(x_fromstore) == ["a", "b"]
46+
end

0 commit comments

Comments
 (0)