Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate empty! #1843

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/dataframe/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,10 @@ Base.setindex!(df::DataFrame, v, ::Colon, col_inds) =

##############################################################################
##
## Mutating AbstractDict methods
## Mutating methods
##
##############################################################################

Base.empty!(df::DataFrame) = (empty!(_columns(df)); empty!(index(df)); df)

"""
Insert a column into a data frame in place.

Expand Down
3 changes: 3 additions & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1400,3 +1400,6 @@ import Base: get

import Base: haskey
@deprecate haskey(df::AbstractDataFrame, key::Any) key in names(df)

import Base: empty!
@deprecate empty!(df::DataFrame) deletecols!(df, 1:ncol(df))
12 changes: 1 addition & 11 deletions test/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,7 @@ end
@test size(similar(df, 2)) == size(missingdf)
end

@testset "Associative methods" begin
df = DataFrame(a=[1, 2], b=[3.0, 4.0])
@test !isempty(df)

dfv = view(df, 1:2, 1:2)

@test empty!(df) === df
@test isempty(eachcol(df))
@test isempty(df)
@test isempty(DataFrame(a=[], b=[]))

@testset "insertcols!" begin
df = DataFrame(a=Union{Int, Missing}[1, 2], b=Union{Float64, Missing}[3.0, 4.0])
@test_throws BoundsError insertcols!(df, 5, :newcol => ["a", "b"], )
@test_throws ErrorException insertcols!(df, 1, :newcol => ["a"])
Expand Down
14 changes: 13 additions & 1 deletion test/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,16 @@ df = DataFrame(Union{Int, Missing}, 2, 2)
end
end

end # module
@testset "empty!" begin
df = DataFrame(a=[1, 2], b=[3.0, 4.0])
@test !isempty(df)

dfv = view(df, 1:2, 1:2)

@test empty!(df) === df
@test isempty(eachcol(df))
@test isempty(df)
@test isempty(DataFrame(a=[], b=[]))
end

end # module