Skip to content

Convert interface to DataFrame #211

Description

@Mutaz94

Quick question regarding converting a solution to DataFrame. If we want to obtain dataframe as the followin, it works

f_2dlinear = (du,u,p,t) -> du.=1.01u;
prob = ODEProblem(f_2dlinear,rand(2,2),(0.0,1.0));
sol1 =solve(prob,Euler();dt=1//2^(4));
df = DataFrame(sol1)

However, if I want to specify a solution e.g.

time_ = [0.0, 0.1, 0.2]
DataFrame(sol1(time_))

I get this error

ERROR: ArgumentError: 'DiffEqArray{Float64, 3, Vector{Matrix{Float64}}, Vector{Float64}, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), SciMLBase.NullParameters}' iterates 'Matrix{Float64}' values, which doesn't satisfy the Tables.jl `AbstractRow` interface
Stacktrace:
 [1] invalidtable(#unused#::DiffEqArray{Float64, 3, Vector{Matrix{Float64}}, Vector{Float64}, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), SciMLBase.NullParameters}, #unused#::Matrix{Float64})
   @ Tables ~/.julia/packages/Tables/PxO1m/src/tofromdatavalues.jl:42
 [2] iterate
   @ ~/.julia/packages/Tables/PxO1m/src/tofromdatavalues.jl:48 [inlined]
 [3] buildcolumns
   @ ~/.julia/packages/Tables/PxO1m/src/fallbacks.jl:197 [inlined]
 [4] columns
   @ ~/.julia/packages/Tables/PxO1m/src/fallbacks.jl:260 [inlined]
 [5] DataFrame(x::DiffEqArray{Float64, 3, Vector{Matrix{Float64}}, Vector{Float64}, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), SciMLBase.NullParameters}; copycols::Nothing)
   @ DataFrames ~/.julia/packages/DataFrames/zqFGs/src/other/tables.jl:58
 [6] DataFrame(x::DiffEqArray{Float64, 3, Vector{Matrix{Float64}}, Vector{Float64}, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), SciMLBase.NullParameters})
   @ DataFrames ~/.julia/packages/DataFrames/zqFGs/src/other/tables.jl:49
 [7] top-level scope
   @ REPL[140]:1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions