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

Deprecate this repository #19

Open
femtotrader opened this issue Jul 10, 2017 · 3 comments
Open

Deprecate this repository #19

femtotrader opened this issue Jul 10, 2017 · 3 comments

Comments

@femtotrader
Copy link
Owner

https://github.com/davidanthoff/IterableTables.jl may help

@femtotrader
Copy link
Owner Author

femtotrader commented Jul 11, 2017

@femtotrader
Copy link
Owner Author

femtotrader commented Jul 19, 2018

https://github.com/femtotrader/TimeSeriesIO.jl/blob/master/test/test_dataframe.jl

DataFrame -> TimeArray

Create DataFrame

julia> using IterableTables

julia> dat = "Date,Stock,Open,High,Low,Close,Volume
              2016-09-29,KESM,7.92,7.98,7.92,7.97,149400
              2016-09-30,KESM,7.96,7.97,7.84,7.9,29900
              2016-10-04,KESM,7.8,7.94,7.8,7.93,99900
              2016-10-05,KESM,7.93,7.95,7.89,7.93,77500
              2016-10-06,KESM,7.93,7.93,7.89,7.92,130600
              2016-10-07,KESM,7.91,7.94,7.91,7.92,103000"
"Date,Stock,Open,High,Low,Close,Volume\n       2016-09-29,KESM,7.92,7.98,7.92,7.97,149400\n       2016-09-30,KESM,7.96,7.97,7.84,7.9,29900\n       2016-10-04,KESM,7.8,7.94,7.8,7.93,99900\n       2016-10-05,KESM,7.93,7.95,7.89,7.93,77500\n       2016-10-06,KESM,7.93,7.93,7.89,7.92,130600\n       2016-10-07,KESM,7.91,7.94,7.91,7.92,103000"

julia> io = IOBuffer(dat)
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=331, maxsize=Inf, ptr=1, mark=-1)

julia> df = CSV.read(io)
6×7 DataFrame
│ Row │ Date              │ Stock │ Open │ High │ Low  │ Close │ Volume │
├─────┼───────────────────┼───────┼──────┼──────┼──────┼───────┼────────┤
│ 12016-09-29 │ KESM  │ 7.927.987.927.97149400 │
│ 22016-09-30 │ KESM  │ 7.967.977.847.929900  │
│ 32016-10-04 │ KESM  │ 7.87.947.87.9399900  │
│ 42016-10-05 │ KESM  │ 7.937.957.897.9377500  │
│ 52016-10-06 │ KESM  │ 7.937.937.897.92130600 │
│ 62016-10-07 │ KESM  │ 7.917.947.917.92103000

Convert to TimeArray

julia> using TimeSeries: TimeArray

julia> TimeArray(df[[:Date, :Open, :High, :Low, :Close]], timestamp_column=:Date)
ERROR: MethodError: no method matching TimeArray(::DataFrame; timestamp_column=:Date)
Closest candidates are:
  TimeArray(::AbstractArray{D<:TimeType,1}, ::AbstractArray{T,N}) where {T, N, D<:TimeType} at /Users/scls/.julia/packages/TimeSeries/DyHME/src/timearray.jl:49 got unsupported keyword argument "timestamp_column"
  TimeArray(::AbstractArray{D<:TimeType,1}, ::AbstractArray{T,N}, ::Array{S<:AbstractString,1}) where {T, N, D<:TimeType, S<:AbstractString} at /Users/scls/.julia/packages/TimeSeries/DyHME/src/timearray.jl:49 got unsupported keyword argument "timestamp_column"
  TimeArray(::AbstractArray{D<:TimeType,1}, ::AbstractArray{T,N}, ::Array{S<:AbstractString,1}, ::Any; args...) where {T, N, D<:TimeType, S<:AbstractString} at /Users/scls/.julia/packages/TimeSeries/DyHME/src/timearray.jl:49
  ...
Stacktrace:
 [1] top-level scope at none:0

@femtotrader
Copy link
Owner Author

TimeSeries.TimeArray -> DataFrames.DataFrame

Create TimeArray

julia> using TimeSeries

julia> dat = "Date,Open,High,Low,Close,Volume
       2012-01-03,11.0,11.25,10.99,11.13,45709900
       2012-01-04,11.15,11.53,11.07,11.3,79725200
       2012-01-05,11.33,11.63,11.24,11.59,67877500
       2012-01-06,11.74,11.8,11.52,11.71,59840700
       2012-01-09,11.83,11.95,11.7,11.8,53981500
       2012-01-10,12.0,12.05,11.63,11.8,121750600
       2012-01-11,11.74,12.18,11.65,12.07,63806000"
"Date,Open,High,Low,Close,Volume\n2012-01-03,11.0,11.25,10.99,11.13,45709900\n2012-01-04,11.15,11.53,11.07,11.3,79725200\n2012-01-05,11.33,11.63,11.24,11.59,67877500\n2012-01-06,11.74,11.8,11.52,11.71,59840700\n2012-01-09,11.83,11.95,11.7,11.8,53981500\n2012-01-10,12.0,12.05,11.63,11.8,121750600\n2012-01-11,11.74,12.18,11.65,12.07,63806000"

julia> io2 = IOBuffer(dat)
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=333, maxsize=Inf, ptr=1, mark=-1)

julia> ta2 = readtimearray(io2)
WARNING: importing deprecated binding Base.readdlm into TimeSeries.
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
WARNING: Base.readdlm is deprecated: it has been moved to the standard library package `DelimitedFiles`.
Add `using DelimitedFiles` to your imports.
 in module TimeSeries
in #readtimearray#29 at /Users/scls/.julia/packages/TimeSeries/DyHME/src/readwrite.jl
┌ Warning: `find(f::Function, A::AbstractVector)` is deprecated, use `findall(f, A)` instead.
│   caller = #readtimearray#29(::Char, ::Nothing, ::String, ::Bool, ::Function, ::Base.GenericIOBuffer{Array{UInt8,1}}) at readwrite.jl:11
└ @ TimeSeries ~/.julia/packages/TimeSeries/DyHME/src/readwrite.jl:11
┌ Warning: `size(x, d1::Integer, d2::Integer)` is deprecated, use `(size(x, d1), size(x, d2))` instead.
│   caller = (::getfield(TimeSeries, Symbol("##call#1#2")))(::Bool, ::Type{TimeArray{Float64,2,Date,Array{Float64,2}}}, ::Array{Date,1}, ::Array{Float64,2}, ::Array{String,1}, ::Nothing) at timearray.jl:28
└ @ TimeSeries ~/.julia/packages/TimeSeries/DyHME/src/timearray.jl:28
┌ Warning: `size(x, d1::Integer, d2::Integer)` is deprecated, use `(size(x, d1), size(x, d2))` instead.
│   caller = show(::IOContext{REPL.Terminals.TTYTerminal}, ::TimeArray{Float64,2,Date,Array{Float64,2}}) at timearray.jl:158
└ @ TimeSeries ~/.julia/packages/TimeSeries/DyHME/src/timearray.jl:158
7x5 TimeArray{Float64,2,Date,Array{Float64,2}} 2012-01-03 to 2012-01-11
┌ Warning: `round(x::Number, digits)` is deprecated, use `round(x; digits=digits)` instead.
│   caller = _showval at timearray.jl:124 [inlined]
└ @ Core ~/.julia/packages/TimeSeries/DyHME/src/timearray.jl:124
┌ Warning: `strwidth` is deprecated, use `textwidth` instead.
│   caller = _broadcast_getindex_evalf at broadcast.jl:574 [inlined]
└ @ Core ./broadcast.jl:574
┌ Warning: `strwidth` is deprecated, use `textwidth` instead.
│   caller = _broadcast_getindex_evalf at broadcast.jl:574 [inlined]
└ @ Core ./broadcast.jl:574
┌ Warning: `maximum(a::AbstractArray, dims)` is deprecated, use `maximum(a, dims=dims)` instead.
│   caller = show(::IOContext{REPL.Terminals.TTYTerminal}, ::TimeArray{Float64,2,Date,Array{Float64,2}}) at timearray.jl:179
└ @ TimeSeries ~/.julia/packages/TimeSeries/DyHME/src/timearray.jl:179
┌ Warning: `strwidth` is deprecated, use `textwidth` instead.
│   caller = show(::IOContext{REPL.Terminals.TTYTerminal}, ::TimeArray{Float64,2,Date,Array{Float64,2}}) at timearray.jl:180
└ @ TimeSeries ~/.julia/packages/TimeSeries/DyHME/src/timearray.jl:180
│            │ Open  │ High  │ Low   │ Close │ Volume     │
├────────────┼───────┼───────┼───────┼───────┼────────────┤
│ 2012-01-03 │ 11.0  │ 11.25 │ 10.99 │ 11.13 │ 4.57099e7  │
│ 2012-01-04 │ 11.15 │ 11.53 │ 11.07 │ 11.3  │ 7.97252e7  │
│ 2012-01-05 │ 11.33 │ 11.63 │ 11.24 │ 11.59 │ 6.78775e7  │
│ 2012-01-06 │ 11.74 │ 11.8  │ 11.52 │ 11.71 │ 5.98407e7  │
│ 2012-01-09 │ 11.83 │ 11.95 │ 11.7  │ 11.8  │ 5.39815e7  │
│ 2012-01-10 │ 12.0  │ 12.05 │ 11.63 │ 11.8  │ 1.217506e8 │
│ 2012-01-11 │ 11.74 │ 12.18 │ 11.65 │ 12.07 │ 6.3806e7   │

Convert to DataFrame

julia> using IterableTables

julia> using DataFrames

julia> DataFrame(ta2)
ERROR: MethodError: Cannot `convert` an object of type TimeArray{Float64,2,Date,Array{Float64,2}} to an object of type DataFrame
Closest candidates are:
  convert(::Type{DataFrame}, ::AbstractArray{T,2} where T) at /Users/scls/.julia/packages/DataFrames/QYzTe/src/dataframe/dataframe.jl:986
  convert(::Type{DataFrame}, ::AbstractDict) at /Users/scls/.julia/packages/DataFrames/QYzTe/src/dataframe/dataframe.jl:988
  convert(::Type{S}, ::T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)) where {S, T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)} at /Users/scls/.julia/packages/CategoricalArrays/04bks/src/value.jl:66
  ...
Stacktrace:
 [1] DataFrame(::TimeArray{Float64,2,Date,Array{Float64,2}}) at /Users/scls/.julia/packages/IterableTables/Jkq8l/src/integrations/dataframes.jl:24
 [2] top-level scope at none:0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant