Skip to content

Commit

Permalink
Merge pull request #1292 from JuliaData/nl/allowmissing!
Browse files Browse the repository at this point in the history
Add one-argument version of allowmissing!()
  • Loading branch information
cjprybol committed Nov 30, 2017
2 parents bbb2503 + 7f6eee1 commit 74eb890
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dataframe/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ function allowmissing!(df::DataFrame, col::ColumnIndex)
df[col] = Vector{Union{eltype(df[col]), Missing}}(df[col])
df
end
function allowmissing!(df::DataFrame, cols::Vector{T}) where T <: ColumnIndex
function allowmissing!(df::DataFrame, cols::AbstractVector{<: ColumnIndex}=1:size(df, 2))
for col in cols
allowmissing!(df, col)
end
Expand Down
6 changes: 6 additions & 0 deletions test/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,13 @@ module TestDataFrame
allowmissing!(df, 1)
@test isa(df[1], Vector{Union{Int, Missing}})
@test !isa(df[2], Vector{Union{Int, Missing}})

df = DataFrame(Any[collect(1:10), collect(1:10)])
allowmissing!(df, [1,2])
@test isa(df[1], Vector{Union{Int, Missing}}) && isa(df[2], Vector{Union{Int, Missing}})

df = DataFrame(Any[collect(1:10), collect(1:10)])
allowmissing!(df)
@test isa(df[1], Vector{Union{Int, Missing}}) && isa(df[2], Vector{Union{Int, Missing}})
end
end

0 comments on commit 74eb890

Please sign in to comment.