diff --git a/src/tables.jl b/src/tables.jl index 7b3eea6..a34f323 100644 --- a/src/tables.jl +++ b/src/tables.jl @@ -2,6 +2,7 @@ Tables.istable(::Type{TSFrame}) = true Tables.rowaccess(::Type{TSFrame}) = true Tables.rows(ts::TSFrame) = DataFrames.eachrow(ts.coredata) +Tables.rowcount(ts::TSFrame) = TSFrames.nrow(ts) Tables.columnaccess(::Type{TSFrame}) = true Tables.columns(ts::TSFrame) = DataFrames.eachcol(ts.coredata) diff --git a/test/tables.jl b/test/tables.jl index 7c8f209..83fc6e8 100644 --- a/test/tables.jl +++ b/test/tables.jl @@ -13,6 +13,14 @@ ts = TSFrame(1:DAYS, dates) @test first(Tables.rows(ts))[:Index] == Date(YEAR, MONTH, 1) @test first(Tables.rows(ts))[:x1] == 1 +# testing Tables.rowcount +@test Tables.rowcount(ts)==15 +@test Tables.rowcount(TSFrame(1:10))==10 +@test Tables.rowcount(TSFrame(1:1))==1 +@test Tables.rowcount(TSFrame(Int))==0 +@test Tables.rowcount(TSFrame(Int,n=1))==0 +@test Tables.rowcount(TSFrame(Int,n=2))==0 + # testing Tables.columns @test Tables.columns(ts).Index == dates @test Tables.columns(ts).x1 == 1:DAYS