Skip to content

Commit

Permalink
isempty(df) should return true if either dimension == 0 (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
rofinn authored and nalimilan committed Sep 13, 2017
1 parent 885078a commit fb72599
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/abstractdataframe/abstractdataframe.jl
Expand Up @@ -254,7 +254,7 @@ end

Base.haskey(df::AbstractDataFrame, key::Any) = haskey(index(df), key)
Base.get(df::AbstractDataFrame, key::Any, default::Any) = haskey(df, key) ? df[key] : default
Base.isempty(df::AbstractDataFrame) = ncol(df) == 0
Base.isempty(df::AbstractDataFrame) = size(df, 1) == 0 || size(df, 2) == 0

##############################################################################
##
Expand Down
1 change: 1 addition & 0 deletions test/dataframe.jl
Expand Up @@ -93,6 +93,7 @@ module TestDataFrame
@test empty!(df) === df
@test isempty(df.columns)
@test isempty(df)
@test isempty(DataFrame(a=[], b=[]))

df = DataFrame(a=Union{Int, Null}[1, 2], b=Union{Float64, Null}[3.0, 4.0])
@test_throws BoundsError insert!(df, 5, ["a", "b"], :newcol)
Expand Down

0 comments on commit fb72599

Please sign in to comment.