Skip to content

Commit

Permalink
Merge pull request #124 from harsharora21/main
Browse files Browse the repository at this point in the history
Add Tables.rowcount
  • Loading branch information
chiraganand authored Dec 5, 2022
2 parents 86f67bd + 8242edd commit 55b9aac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55b9aac

Please sign in to comment.