Skip to content

Commit 34624f3

Browse files
authored
Require Julia 1.6 (#3145)
1 parent b01fd38 commit 34624f3

27 files changed

+170
-425
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
version:
15-
- '1.0'
1615
- '1.6'
1716
- '1' # automatically expands to the latest stable 1.x release of Julia
1817
- 'nightly'

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# DataFrames.jl v1.4 Release Notes
22

3+
## Julia compatibility change
4+
5+
* DataFrames.jl 1.4 requires Julia 1.6
6+
([#3145](https://github.com/JuliaData/DataFrames.jl/pull/3145))
7+
38
## New functionalities
49

510
* `subset` and `subset!` now allow passing zero column selectors

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
2525

2626
[compat]
2727
CategoricalArrays = "0.10.0"
28-
Compat = "3.46, 4.2"
28+
Compat = "4.2"
2929
DataAPI = "1.11"
3030
InvertedIndices = "1"
3131
IteratorInterfaceExtensions = "0.1.1, 1"
@@ -38,7 +38,7 @@ SortingAlgorithms = "0.1, 0.2, 0.3, 1"
3838
TableTraits = "0.4, 1"
3939
Tables = "1.8.1"
4040
Unitful = "1"
41-
julia = "1"
41+
julia = "1.6"
4242

4343
[extras]
4444
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"

src/DataFrames.jl

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,8 @@ export AbstractDataFrame,
107107
deletecolmetadata!,
108108
emptycolmetadata!
109109

110-
if VERSION >= v"1.1.0-DEV.792"
111-
import Base.eachcol, Base.eachrow
112-
else
113-
import Compat.eachcol, Compat.eachrow
114-
export eachcol, eachrow
115-
end
116-
117-
if VERSION < v"1.2"
118-
export hasproperty
119-
end
120-
121-
if isdefined(Base, :only) # Introduced in 1.4.0
122-
import Base.only
123-
else
124-
import Compat.only
125-
export only
126-
end
110+
using Base.Threads: @spawn
111+
using Base: ComposedFunction
127112

128113
if isdefined(Base, :keepat!) # Introduced in 1.7.0
129114
import Base.keepat!
@@ -132,48 +117,18 @@ else
132117
export keepat!
133118
end
134119

135-
if isdefined(Base, :popat!) # Introduced in 1.5.0
136-
import Base.popat!
137-
else
138-
import Compat.popat!
139-
export popat!
140-
end
141-
142-
if VERSION >= v"1.3"
143-
using Base.Threads: @spawn
144-
else
145-
# This is the definition of @async in Base
146-
macro spawn(expr)
147-
thunk = esc(:(()->($expr)))
148-
var = esc(Base.sync_varname)
149-
quote
150-
local task = Task($thunk)
151-
if $(Expr(:isdefined, var))
152-
push!($var, task)
153-
end
154-
schedule(task)
155-
end
156-
end
157-
end
158-
159-
if isdefined(Base, :ComposedFunction) # Julia >= 1.6.0-DEV.85
160-
using Base: ComposedFunction
120+
if VERSION >= v"1.9.0-DEV.1163"
121+
import Base: stack
161122
else
162-
using Compat: ComposedFunction
123+
import Compat: stack
124+
export stack
163125
end
164126

165127
const METADATA_FIXED =
166128
"""
167129
Metadata: this function preserves table-level and column-level `:note`-style metadata.
168130
"""
169131

170-
if VERSION >= v"1.9.0-DEV.1163"
171-
import Base: stack
172-
else
173-
import Compat: stack
174-
export stack
175-
end
176-
177132
include("other/utils.jl")
178133
include("other/index.jl")
179134

src/abstractdataframe/abstractdataframe.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,6 @@ Return `true` if data frame `df` has zero rows, and `false` otherwise.
403403
"""
404404
Base.isempty(df::AbstractDataFrame) = nrow(df) == 0
405405

406-
if VERSION < v"1.6"
407-
Base.firstindex(df::AbstractDataFrame, i::Integer) = first(axes(df, i))
408-
Base.lastindex(df::AbstractDataFrame, i::Integer) = last(axes(df, i))
409-
end
410406
Base.axes(df::AbstractDataFrame, i::Integer) = Base.OneTo(size(df, i))
411407

412408
"""
@@ -514,7 +510,7 @@ If `df` has a single row return it as a `DataFrameRow`; otherwise throw `Argumen
514510
515511
$METADATA_FIXED
516512
"""
517-
function only(df::AbstractDataFrame)
513+
function Base.only(df::AbstractDataFrame)
518514
nrow(df) != 1 && throw(ArgumentError("data frame must contain exactly 1 row"))
519515
return df[1, :]
520516
end

src/abstractdataframe/iteration.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ julia> eachrow(view(df, [4, 3], [2, 1]))
7272
2 │ 13 3
7373
```
7474
"""
75-
eachrow(df::AbstractDataFrame) = DataFrameRows(df)
75+
Base.eachrow(df::AbstractDataFrame) = DataFrameRows(df)
7676

7777
Base.IndexStyle(::Type{<:DataFrameRows}) = Base.IndexLinear()
7878
Base.size(itr::DataFrameRows) = (size(parent(itr), 1), )
@@ -172,7 +172,7 @@ julia> sum.(eachcol(df))
172172
50
173173
```
174174
"""
175-
eachcol(df::AbstractDataFrame) = DataFrameColumns(df)
175+
Base.eachcol(df::AbstractDataFrame) = DataFrameColumns(df)
176176

177177
Base.IteratorSize(::Type{<:DataFrameColumns}) = Base.HasShape{1}()
178178
Base.size(itr::DataFrameColumns) = (size(parent(itr), 2),)
@@ -191,10 +191,6 @@ Base.eltype(::Type{<:DataFrameColumns}) = AbstractVector
191191
Base.firstindex(itr::DataFrameColumns) = 1
192192
Base.lastindex(itr::DataFrameColumns) = length(itr)
193193

194-
if VERSION < v"1.6"
195-
Base.firstindex(itr::DataFrameColumns, i::Integer) = first(axes(itr, i))
196-
Base.lastindex(itr::DataFrameColumns, i::Integer) = last(axes(itr, i))
197-
end
198194
Base.axes(itr::DataFrameColumns, i::Integer) = Base.OneTo(size(itr, i))
199195

200196
Base.iterate(itr::DataFrameColumns, i::Integer=1) =

src/abstractdataframe/show.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@ function ourshow(io::IO, x::Markdown.MD, truncstring::Int)
5959
return print(io, len < length(r) - 1 ? first(r, len)*'' : first(r, len))
6060
end
6161

62-
# AbstractChar: https://github.com/JuliaLang/julia/pull/34730 (1.5.0-DEV.261)
63-
# Irrational: https://github.com/JuliaLang/julia/pull/34741 (1.5.0-DEV.266)
64-
if VERSION < v"1.5.0-DEV.261" || VERSION < v"1.5.0-DEV.266"
65-
function ourshow(io::IO, x::T, truncstring::Int) where T <: Union{AbstractChar, Irrational}
66-
io = IOContext(io, :compact=>get(io, :compact, true), :typeinfo=>typeof(x))
67-
show(io, x)
68-
end
69-
end
70-
7162
# For most data frames, especially wide, columns having the same element type
7263
# occur multiple times. batch_compacttype ensures that we compute string
7364
# representation of a specific column element type only once and then reuse it.

src/dataframe/dataframe.jl

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,9 @@ mutable struct DataFrame <: AbstractDataFrame
212212

213213
# we write into columns as we know that it is guaranteed
214214
# that it was freshly allocated in the outer constructor
215-
@static if VERSION >= v"1.4"
216-
if copycols && len >= 1_000_000 && length(columns) > 1 && Threads.nthreads() > 1
217-
@sync for i in eachindex(columns)
218-
Threads.@spawn columns[i] = _preprocess_column(columns[i], len, copycols)
219-
end
220-
else
221-
for i in eachindex(columns)
222-
columns[i] = _preprocess_column(columns[i], len, copycols)
223-
end
215+
if copycols && len >= 1_000_000 && length(columns) > 1 && Threads.nthreads() > 1
216+
@sync for i in eachindex(columns)
217+
Threads.@spawn columns[i] = _preprocess_column(columns[i], len, copycols)
224218
end
225219
else
226220
for i in eachindex(columns)
@@ -564,20 +558,15 @@ function _threaded_getindex(selected_rows::AbstractVector,
564558
selected_columns::AbstractVector,
565559
df_columns::AbstractVector,
566560
idx::AbstractIndex)
567-
@static if VERSION >= v"1.4"
568-
if length(selected_rows) >= 1_000_000 && Threads.nthreads() > 1
569-
new_columns = Vector{AbstractVector}(undef, length(selected_columns))
570-
@sync for i in eachindex(new_columns)
571-
Threads.@spawn new_columns[i] = df_columns[selected_columns[i]][selected_rows]
572-
end
573-
return DataFrame(new_columns, idx, copycols=false)
574-
else
575-
return DataFrame(AbstractVector[df_columns[i][selected_rows] for i in selected_columns],
576-
idx, copycols=false)
561+
if length(selected_rows) >= 1_000_000 && Threads.nthreads() > 1
562+
new_columns = Vector{AbstractVector}(undef, length(selected_columns))
563+
@sync for i in eachindex(new_columns)
564+
Threads.@spawn new_columns[i] = df_columns[selected_columns[i]][selected_rows]
577565
end
566+
return DataFrame(new_columns, idx, copycols=false)
578567
else
579568
return DataFrame(AbstractVector[df_columns[i][selected_rows] for i in selected_columns],
580-
idx, copycols=false)
569+
idx, copycols=false)
581570
end
582571
end
583572

@@ -1181,7 +1170,7 @@ julia> df
11811170
2 │ 3 6
11821171
```
11831172
"""
1184-
function popat!(df::DataFrame, i::Integer)
1173+
function Base.popat!(df::DataFrame, i::Integer)
11851174
i isa Bool && throw(ArgumentError("Invalid index of type Bool"))
11861175
nt = NamedTuple(df[i, :])
11871176
deleteat!(df, i)

src/dataframerow/dataframerow.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,6 @@ Base.ndims(::Type{<:DataFrameRow}) = 1
386386
Base.firstindex(r::DataFrameRow) = 1
387387
Base.lastindex(r::DataFrameRow) = length(r)
388388

389-
if VERSION < v"1.6"
390-
Base.firstindex(r::DataFrameRow, i::Integer) = first(axes(r, i))
391-
Base.lastindex(r::DataFrameRow, i::Integer) = last(axes(r, i))
392-
end
393389
Base.axes(r::DataFrameRow, i::Integer) = Base.OneTo(size(r, i))
394390

395391
Base.iterate(r::DataFrameRow) = iterate(r, 1)

src/groupeddataframe/complextransforms.jl

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,8 @@ function _combine_rows_with_first!((firstrow,)::Ref{Any},
264264
# Create up to one task per thread
265265
# This has lower overhead than creating one task per group,
266266
# but is optimal only if operations take roughly the same time for all groups
267-
if VERSION >= v"1.4" && threads && isthreadsafe(outcols, incols)
268-
basesize = max(1, cld(len - 1, Threads.nthreads()))
269-
partitions = Iterators.partition(2:len, basesize)
270-
else
271-
partitions = (2:len,)
272-
end
267+
basesize = max(1, cld(len - 1, Threads.nthreads()))
268+
partitions = Iterators.partition(2:len, basesize)
273269
widen_type_lock = ReentrantLock()
274270
outcolsref = Ref{NTuple{<:Any, AbstractVector}}(outcols)
275271
type_widened = fill(false, length(partitions))
@@ -320,16 +316,9 @@ end
320316

321317
# This needs to be in a separate function
322318
# to work around a crash due to JuliaLang/julia#29430
323-
if VERSION >= v"1.1.0-DEV.723"
324-
@inline function do_append!(do_it, col, vals)
325-
do_it && append!(col, vals)
326-
return do_it
327-
end
328-
else
329-
@noinline function do_append!(do_it, col, vals)
330-
do_it && append!(col, vals)
331-
return do_it
332-
end
319+
@inline function do_append!(do_it, col, vals)
320+
do_it && append!(col, vals)
321+
return do_it
333322
end
334323

335324
_get_col(rows::AbstractDataFrame, j::Int) = rows[!, j]

0 commit comments

Comments
 (0)