From 4abe13867cd674d33e3af78e63e008db852c1672 Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Sat, 23 Dec 2017 22:42:06 +0100 Subject: [PATCH] Fix failure due to calling pairs() on keyword arguments on Julia 0.6 (#1329) --- src/DataFrames.jl | 6 +++++- src/abstractdataframe/sort.jl | 2 +- src/dataframe/dataframe.jl | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/DataFrames.jl b/src/DataFrames.jl index 97439fbc79..d93b90fb7c 100644 --- a/src/DataFrames.jl +++ b/src/DataFrames.jl @@ -10,8 +10,12 @@ module DataFrames using Reexport, StatsBase, SortingAlgorithms, Compat @reexport using CategoricalArrays, Missings using Base: Sort, Order -using Compat: pairs +if VERSION >= v"0.7.0-DEV.2738" + const kwpairs = pairs +else + kwpairs(x::AbstractArray) = (first(v) => last(v) for v in x) +end if VERSION >= v"0.7.0-DEV.2915" using Unicode end diff --git a/src/abstractdataframe/sort.jl b/src/abstractdataframe/sort.jl index db7bf98234..75e4f9cffd 100644 --- a/src/abstractdataframe/sort.jl +++ b/src/abstractdataframe/sort.jl @@ -30,7 +30,7 @@ _getcol(x) = x # Get an Ordering for a single column ### function ordering(col_ord::UserColOrdering, lt::Function, by::Function, rev::Bool, order::Ordering) - for (k,v) in pairs(col_ord.kwargs) + for (k,v) in kwpairs(col_ord.kwargs) if k == :lt; lt = v elseif k == :by; by = v elseif k == :rev; rev = v diff --git a/src/dataframe/dataframe.jl b/src/dataframe/dataframe.jl index cd72bd2093..3fad35822d 100644 --- a/src/dataframe/dataframe.jl +++ b/src/dataframe/dataframe.jl @@ -116,7 +116,7 @@ function DataFrame(; kwargs...) if isempty(kwargs) DataFrame(Any[], Index()) else - DataFrame((k => v for (k,v) in pairs(kwargs))...) + DataFrame(kwpairs(kwargs)...) end end