Skip to content
Open
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
13 changes: 9 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Future = "9fa8497b-333b-5362-9e8d-4d0656e87820"
InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
InvertedIndices = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -19,21 +18,25 @@ PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TableTraits = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[weakdeps]
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c"

[extensions]
DataFramesSentinelArraysExt = "SentinelArrays"

[compat]
CategoricalArrays = "0.10.0, 1"
Combinatorics = "1.0.2"
Compat = "4.2"
DataAPI = "1.16.0"
DataStructures = "0.18, 0.19"
DataValues = "0.4.13"
InlineStrings = "1.3.0"
InvertedIndices = "1.3"
IteratorInterfaceExtensions = "0.1.1, 1"
Missings = "0.4.2, 1"
Expand All @@ -57,13 +60,15 @@ CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
DataValues = "e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["CategoricalArrays", "Combinatorics", "DataValues", "Dates", "Logging", "OffsetArrays", "ShiftedArrays", "SparseArrays", "StableRNGs", "Test", "Unitful"]
test = ["CategoricalArrays", "Combinatorics", "DataValues", "Dates", "InlineStrings", "Logging", "OffsetArrays", "SentinelArrays", "ShiftedArrays", "SparseArrays", "StableRNGs", "Test", "Unitful"]
22 changes: 22 additions & 0 deletions ext/DataFramesSentinelArraysExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module DataFramesSentinelArraysExt

using DataFrames
using DataFrames: SymbolOrString
using SentinelArrays: ChainedVector

# definition needed to avoid dispatch ambiguity between the `reduce(vcat, ...)`
# methods defined in DataFrames and the one defined in SentinelArrays for
# `ChainedVector`
Base.reduce(::typeof(vcat),
dfs::Union{ChainedVector{AbstractDataFrame,<:AbstractVector{AbstractDataFrame}},
ChainedVector{DataFrame,<:AbstractVector{DataFrame}},
ChainedVector{SubDataFrame,<:AbstractVector{SubDataFrame}},
ChainedVector{Union{DataFrame,SubDataFrame},<:AbstractVector{Union{DataFrame,SubDataFrame}}}};
cols::Union{Symbol,AbstractVector{Symbol},
AbstractVector{<:AbstractString}}=:setequal,
source::Union{Nothing,SymbolOrString,
Pair{<:SymbolOrString,<:AbstractVector}}=nothing,
init::AbstractDataFrame=DataFrame()) =
reduce(vcat, collect(AbstractDataFrame, dfs), cols=cols, source=source, init=init)

end # module
2 changes: 0 additions & 2 deletions src/DataFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import Base.keepat!,
Base.stack,
LinearAlgebra.norm,
PrecompileTools,
SentinelArrays,
InlineStrings,
DataAPI,
DataAPI.allcombinations,
DataAPI.All,
Expand Down
13 changes: 0 additions & 13 deletions src/abstractdataframe/iteration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -748,19 +748,6 @@ function Base.reduce(::typeof(vcat),
return res
end

# definition needed to avoid dispatch ambiguity
Base.reduce(::typeof(vcat),
dfs::Union{SentinelArrays.ChainedVector{AbstractDataFrame,<:AbstractVector{AbstractDataFrame}},
SentinelArrays.ChainedVector{DataFrame,<:AbstractVector{DataFrame}},
SentinelArrays.ChainedVector{SubDataFrame,<:AbstractVector{SubDataFrame}},
SentinelArrays.ChainedVector{Union{DataFrame,SubDataFrame},<:AbstractVector{Union{DataFrame,SubDataFrame}}}};
cols::Union{Symbol,AbstractVector{Symbol},
AbstractVector{<:AbstractString}}=:setequal,
source::Union{Nothing,SymbolOrString,
Pair{<:SymbolOrString,<:AbstractVector}}=nothing,
init::AbstractDataFrame=DataFrame()) =
reduce(vcat, collect(AbstractDataFrame, dfs), cols=cols, source=source, init=init)

function _vcat(dfs::AbstractVector{AbstractDataFrame};
cols::Union{Symbol,AbstractVector{Symbol},
AbstractVector{<:AbstractString}}=:setequal)
Expand Down
7 changes: 4 additions & 3 deletions test/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1942,10 +1942,11 @@ end
@test_throws ArgumentError reduce(vcat, dfs, cols=:union, source=:x, init=DataFrame(c=[1]))
end

@testset "vcat ChainedVector ambiguity" begin
dfs = DataFrames.SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(a=2)]])
import SentinelArrays
@testset "vcat ChainedVector" begin
dfs = SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(a=2)]])
@test reduce(vcat, dfs) == DataFrame(a=1:2)
dfs = DataFrames.SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(b=2)]])
dfs = SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(b=2)]])
@test reduce(vcat, dfs, cols=:union, source=:x, init=DataFrame(c=[])) ≅
DataFrame(c=missing, a=[1, missing], b=[missing, 2], x=1:2)
end
Expand Down
Loading