You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 4, 2019. It is now read-only.
Subtracting two DataArray{DateTime} arrays currently doesn't work:
julia>using DataFrames
julia> df =DataFrame()
0x0 DataFrames.DataFrame
julia> df[:A] = [DateTime(2015,1,1), DateTime(2015,1,2)]
2-element Array{DateTime,1}:2015-01-01T00:00:002015-01-02T00:00:00
julia> df[:B] = [DateTime(2015,2,1), DateTime(2015,2,2)]
2-element Array{DateTime,1}:2015-02-01T00:00:002015-02-02T00:00:00
julia> df[:A] - df[:B]
ERROR: MethodError: Cannot `convert` an object of type Base.Dates.Millisecond to an object of type DateTime
This may have arisen from a call to the constructor DateTime(...),
since type constructors fall back to convert methods.
Closest candidates are:convert(::Type{DateTime}, ::Date)
convert{R<:Real}(::Type{DateTime}, ::R<:Real)
convert{T}(::Type{T}, ::T)
...
[inlined code] from ./dates/arithmetic.jl:9in-(::DataArrays.DataArray{DateTime,1}, ::DataArrays.DataArray{DateTime,1}) at /Users/omus/.julia/v0.5/DataArrays/src/operators.jl:332ineval(::Module, ::Any) at ./boot.jl:236
julia>Array{DateTime}(df[:A]) -Array{DateTime}(df[:B])
2-element Array{Base.Dates.Millisecond,1}:-2678400000 milliseconds
-2678400000 milliseconds
From my brief investigation into the issue it appears that promote_type is used to determine the type of the produced DataArray. Wouldn't it make more sense to use promote_op for this?
Yes, I had noticed this too at JuliaData/DataFrames.jl#937. Pull request welcome! Note that this should probably be Base.promote_op(@functorize(-), ..) for type stability in Julia 0.4 (see JuliaLang/Compat.jl#184).
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Subtracting two
DataArray{DateTime}
arrays currently doesn't work:From my brief investigation into the issue it appears that
promote_type
is used to determine the type of the producedDataArray
. Wouldn't it make more sense to usepromote_op
for this?The text was updated successfully, but these errors were encountered: