Skip to content

Commit

Permalink
Support HDFStore
Browse files Browse the repository at this point in the history
  • Loading branch information
malmaud committed Mar 26, 2019
1 parent 377e29b commit 95a06d6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ before_install:
- sudo pip3 install numpy
- sudo pip3 install Cython
- sudo pip3 install pandas
- sudo pip3 install tables
8 changes: 6 additions & 2 deletions src/Pandas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import Base: getindex, setindex!, length, size, show, merge, convert,
join, replace, lastindex, sum, abs, any, count,
cumprod, cumsum, diff, filter, first, last,
min, sort, truncate, +, -, *, /, !,
==, >, <, >=, <=, !=, &, |
==, >, <, >=, <=, !=, &, |,
keys, close, get
import Statistics: mean, std, var, cov, median, quantile


Expand Down Expand Up @@ -219,6 +220,7 @@ end
@pytype GroupBy ()->pandas_raw.core.groupby."DataFrameGroupBy"
@pytype SeriesGroupBy ()->pandas_raw.core.groupby."SeriesGroupBy"
@pytype Rolling () -> pandas_raw.core.window."Rolling"
@pytype HDFStore () -> pandas_raw.io.pytables.HDFStore

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

Base.size(x::Union{Loc, Iloc, Ix}) = x.pyo.obj.shape
Base.size(df::PandasWrapped, i::Integer) = size(df)[i]
Expand Down Expand Up @@ -279,6 +282,7 @@ end
@pyasvec Index
@pyasvec GroupBy
@pyasvec Rolling
@pyasvec HDFStore

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

Expand All @@ -293,7 +297,7 @@ for m in [:read_pickle, :read_csv, :read_html, :read_json, :read_excel, :read_ta
:rolling_cov, :expanding_cov, :rolling_skew, :expanding_skew, :rolling_kurt,
:expanding_kurt, :rolling_apply, :expanding_apply, :rolling_quantile,
:expanding_quantile, :rolling_window, :to_numeric, :read_sql, :read_sql_table,
:read_sql_query]
:read_sql_query, :read_hdf]
@eval begin
function $m(args...; kwargs...)
method = pandas_raw.$(string(m))
Expand Down
7 changes: 6 additions & 1 deletion src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ tz_localize,
unstack,
var,
weekday,
read_sql
read_sql,
read_hdf,
HDFStore,
info,
put,
walk

if !isdefined(Base, :drop)
export drop
Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ x = Series([3,5], index=[:a, :b])
# Rolling
roll = rolling(Series([1,2,3,4,5]), 3)
@test isequal(values(mean(roll)), [NaN, NaN, 2.0, 3.0, 4.0])

# HDF
mktempdir() do dir
store = HDFStore("$(dir)/store.h5")
x = Series(["a", "b"])
store["x"] = x
x_fromstore = store["x"]
@test values(x_fromstore) == ["a", "b"]
end

0 comments on commit 95a06d6

Please sign in to comment.