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

remove deprecations and CategoricalArrays.jl dependency #2554

Merged
merged 10 commits into from
Nov 27, 2020
25 changes: 25 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# DataFrames v1.0 Release Notes

## Breaking changes

* No breaking changes are planned for v1.0 release

## Bug fixes

* fixed bug when displaying floating point columns with eltype turned off in
bkamins marked this conversation as resolved.
Show resolved Hide resolved
text/plain ([2542](https://github.com/JuliaData/DataFrames.jl/pull/2542))

## New functionalities


## Deprecated

* all old deprecations now throw an error
([]())
bkamins marked this conversation as resolved.
Show resolved Hide resolved
bkamins marked this conversation as resolved.
Show resolved Hide resolved

## Dependency changes


## Other relevant changes


# DataFrames v0.22 Release Notes

## Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion src/DataFrames.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DataFrames

using Statistics, Printf, REPL
using Reexport, SortingAlgorithms, Compat, Unicode, PooledArrays, CategoricalArrays
using Reexport, SortingAlgorithms, Compat, Unicode, PooledArrays
@reexport using Missings, InvertedIndices
using Base.Sort, Base.Order, Base.Iterators
using TableTraits, IteratorInterfaceExtensions
Expand Down
17 changes: 6 additions & 11 deletions src/abstractdataframe/abstractdataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -556,19 +556,14 @@ julia> describe(df, :min, sum => :sum, cols=:x)
1 │ x 0.1 5.5
```
"""
function DataAPI.describe(df::AbstractDataFrame, stats::Union{Symbol,
Pair{<:Base.Callable, <:SymbolOrString},
Pair{<:SymbolOrString}}...; # TODO: remove after deprecation
cols=:)
if any(x -> x isa Pair{<:SymbolOrString}, stats)
Base.depwarn("name => function order is deprecated; use function => name instead", :describe)
end
return _describe(select(df, cols, copycols=false),
Any[s isa Pair{<:SymbolOrString} ? last(s) => first(s) : s for s in stats])
end
DataAPI.describe(df::AbstractDataFrame,
stats::Union{Symbol, Pair{<:Base.Callable, <:SymbolOrString}}...;
cols=:) =
_describe(select(df, cols, copycols=false), Any[s for s in stats])

DataAPI.describe(df::AbstractDataFrame; cols=:) =
_describe(select(df, cols, copycols=false),
[:mean, :min, :median, :max, :nmissing, :eltype])
Any[:mean, :min, :median, :max, :nmissing, :eltype])
bkamins marked this conversation as resolved.
Show resolved Hide resolved
bkamins marked this conversation as resolved.
Show resolved Hide resolved

function _describe(df::AbstractDataFrame, stats::AbstractVector)
predefined_funs = Symbol[s for s in stats if s isa Symbol]
Expand Down
4 changes: 0 additions & 4 deletions src/abstractdataframe/selection.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# TODO:
# * add handling of empty ByRow to filter, and select/transform/combine for GroupedDataFrame
# * add handling of multiple column return rules for select/transform/combine for GroupedDataFrame

# normalize_selection function makes sure that whatever input format of idx is it
# will end up in one of four canonical forms
# 1) AbstractVector{Int}
Expand Down
141 changes: 2 additions & 139 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,147 +1,10 @@
import Base: @deprecate
# commenting out till we decide to start deprecating things again

@deprecate DataFrame!(args...; kwargs...) DataFrame(args...; copycols=false, kwargs...)
# import Base: @deprecate

# TODO: remove these definitions in year 2021
by(args...; kwargs...) = throw(ArgumentError("by function was removed from DataFrames.jl. " *
"Use the `combine(groupby(...), ...)` or `combine(f, groupby(...))` instead."))

aggregate(args...; kwargs...) = throw(ArgumentError("aggregate function was removed from DataFrames.jl. " *
"Use the `combine` function instead."))
bkamins marked this conversation as resolved.
Show resolved Hide resolved

export categorical, categorical!
function CategoricalArrays.categorical(df::AbstractDataFrame,
cols::Union{ColumnIndex, MultiColumnIndex};
compress::Union{Bool, Nothing}=nothing)
if compress === nothing
compress = false
categoricalstr = "categorical"
else
categoricalstr = "(x -> categorical(x, compress=$compress))"
end
if cols isa AbstractVector{<:Union{AbstractString, Symbol}}
Base.depwarn("`categorical(df, cols)` is deprecated. " *
"Use `transform(df, cols .=> $categoricalstr, renamecols=false)` instead.",
:categorical)
return transform(df, cols .=> (x -> categorical(x, compress=compress)), renamecols=false)
elseif cols isa Union{AbstractString, Symbol}
Base.depwarn("`categorical(df, cols)` is deprecated. " *
"Use `transform(df, cols => $categoricalstr, renamecols=false)` instead.",
:categorical)
return transform(df, cols => (x -> categorical(x, compress=compress)), renamecols=false)
else
Base.depwarn("`categorical(df, cols)` is deprecated. " *
"Use `transform(df, names(df, cols) .=> $categoricalstr, renamecols=false)` instead.",
:categorical)
return transform(df, names(df, cols) .=> (x -> categorical(x, compress=compress)), renamecols=false)
end
end

function CategoricalArrays.categorical(df::AbstractDataFrame,
cols::Union{Type, Nothing}=nothing;
compress::Bool=false)
if compress === nothing
compress = false
categoricalstr = "categorical"
else
categoricalstr = "categorical(x, compress=$compress)"
end
if cols === nothing
cols = Union{AbstractString, Missing}
Base.depwarn("`categorical(df)` is deprecated. " *
"Use `transform(df, names(df, $cols) .=> $categoricalstr, renamecols=false)` instead.",
:categorical)
else
Base.depwarn("`categorical(df, T)` is deprecated. " *
"Use transform(df, names(df, T) .=> $categoricalstr, renamecols=false)` instead.",
:categorical)
end
return transform(df, names(df, cols) .=> (x -> categorical(x, compress=compress)), renamecols=false)
end

function categorical!(df::DataFrame, cols::Union{ColumnIndex, MultiColumnIndex};
compress::Union{Bool, Nothing}=nothing)
if compress === nothing
compress = false
categoricalstr = "categorical"
else
categoricalstr = "(x -> categorical(x, compress=$compress))"
end
if cols isa AbstractVector{<:Union{AbstractString, Symbol}}
Base.depwarn("`categorical!(df, cols)` is deprecated. " *
"Use `transform!(df, cols .=> $categoricalstr, renamecols=false)` instead.",
:categorical!)
return transform!(df, cols .=> (x -> categorical(x, compress=compress)), renamecols=false)
elseif cols isa Union{AbstractString, Symbol}
Base.depwarn("`categorical!(df, cols)` is deprecated. " *
"Use `transform!(df, cols => $categoricalstr, renamecols=false)` instead.",
:categorical!)
return transform!(df, cols => (x -> categorical(x, compress=compress)), renamecols=false)
else
Base.depwarn("`categorical!(df, cols)` is deprecated. " *
"Use `transform!(df, names(df, cols) .=> $categoricalstr, renamecols=false)` instead.",
:categorical!)
return transform!(df, names(df, cols) .=> (x -> categorical(x, compress=compress)), renamecols=false)
end
end

function categorical!(df::DataFrame, cols::Union{Type, Nothing}=nothing;
compress::Bool=false)
if compress === nothing
compress = false
categoricalstr = "categorical"
else
categoricalstr = "(x -> categorical(x, compress=$compress))"
end
if cols === nothing
cols = Union{AbstractString, Missing}
Base.depwarn("`categorical!(df)` is deprecated. " *
"Use `transform!(df, names(df, $cols) .=> $categoricalstr, renamecols=false)` instead.",
:categorical!)
else
Base.depwarn("`categorical!(df, T)` is deprecated. " *
"Use `transform!(df, names(df, T) .=> $categoricalstr, renamecols=false)` instead.",
:categorical!)
end
return transform!(df, names(df, cols) .=> (x -> categorical(x, compress=compress)), renamecols=false)
end

@deprecate DataFrame(pairs::NTuple{N, Pair}; makeunique::Bool=false,
copycols::Bool=true) where {N} DataFrame(pairs..., makeunique=makeunique, copycols=copycols)
@deprecate DataFrame(columns::NTuple{N, AbstractVector}, cnames::NTuple{N, Symbol}; makeunique::Bool=false,
copycols::Bool=true) where {N} DataFrame(collect(columns), collect(cnames);
makeunique=makeunique, copycols=copycols)
@deprecate DataFrame(columns::NTuple{N, AbstractVector}, cnames::NTuple{N, AbstractString}; makeunique::Bool=false,
copycols::Bool=true) where {N} DataFrame(collect(columns), [Symbol(c) for c in cnames];
makeunique=makeunique, copycols=copycols)
@deprecate DataFrame(columns::NTuple{N, AbstractVector};
copycols::Bool=true) where {N} DataFrame(collect(columns),
Symbol.(:x, 1:length(columns)), copycols=copycols)

# this deprecation is very important, becuase without it users will
# get strange results with old code as described in https://github.com/JuliaData/Tables.jl/issues/208
@deprecate DataFrame(columns::AbstractVector{<:AbstractVector}; makeunique::Bool=false,
copycols::Bool=true) DataFrame(columns, :auto, copycols=copycols)
bkamins marked this conversation as resolved.
Show resolved Hide resolved

@deprecate DataFrame(columns::AbstractMatrix) DataFrame(columns, :auto)

function DataFrame(column_eltypes::AbstractVector{T}, cnames::AbstractVector{Symbol},
nrows::Integer=0; makeunique::Bool=false)::DataFrame where T<:Type
Base.depwarn("`DataFrame` constructor with passed eltypes is deprecated. " *
"Pass explicitly created columns to a `DataFrame` constructor instead.",
:DataFrame)
columns = AbstractVector[elty >: Missing ?
fill!(Tables.allocatecolumn(elty, nrows), missing) :
Tables.allocatecolumn(elty, nrows)
for elty in column_eltypes]
return DataFrame(columns, Index(convert(Vector{Symbol}, cnames),
makeunique=makeunique), copycols=false)
end

DataFrame(column_eltypes::AbstractVector{<:Type},
cnames::AbstractVector{<:AbstractString},
nrows::Integer=0; makeunique::Bool=false) =
DataFrame(column_eltypes, Symbol.(cnames), nrows; makeunique=makeunique)

import Base: convert
@deprecate convert(::Type{DataFrame}, A::AbstractMatrix) DataFrame(Tables.table(A, header=Symbol.(:x, axes(A, 2))))
1 change: 1 addition & 0 deletions test/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ end
DataFrame(variable=:a, min=1, min2=1, max2=2, max=2)

@test_throws ArgumentError describe(df, :mean, :all)
@test_throws MethodError describe(DataFrame(a=[1, 2]), cols = :a, "max2" => maximum)
end

@testset "append!" begin
Expand Down
Loading