I wish to create a new subtype of AbstractDataFrame that has a single DataFrame member. I then want to forward the AbstractDataFrame interface to the DataFrame member. Something like:
using DataFrames
using Lazy
struct DFWrapper <: AbstractDataFrame
df::DataFrame
other
stuff
end
@forward DFWrapper.df DataFrames.describe, Base.summary, Base.hcat, Base.vcat,
Base.repeat, Base.names, DataFrames.rename!, Base.length, Base.size,
Base.first, Base.last, Base.convert, DataFrames.completecases,
DataFrames.dropmissing, DataFrames.dropmissing!, DataFrames.nonunique,
Base.unique, Base.unique!, DataFrames.disallowmissing, DataFrames.disallowmissing!,
DataFrames.allowmissing, DataFrames.allowmissing!, DataFrames.categorical, DataFrames.categorical!,
Base.similar, Base.filter, Base.filter!
DFW = DFWrapper(DataFrame(A=1:10), 1.0, false)
I obtained the list of methods being forwarded form here.
Running in the REPL, I get:
Error showing value of type DFWrapper:
ERROR: StackOverflowError:
Stacktrace:
[1] _check_consistency(::DFWrapper) at /dataframe/dataframe.jl:296 (repeats 80000 times)
line 296 is
_check_consistency(df::AbstractDataFrame) = _check_consistency(parent(df))
Forwarding DataFrames._check_consistency
then produces
Error showing value of type DFWrapper:
ERROR: MethodError: no method matching getindex(::DFWrapper, ::typeof(!), ::Symbol)
Closest candidates are:
getindex(::AbstractDataFrame, ::Integer, ::Union{Regex, AbstractArray{T,1} where T, All, Between, InvertedIndex}) at /Users/gerlacar/.julia/packages/DataFrames/S3ZFo/src/dataframerow/dataframerow.jl:90
getindex(::AbstractDataFrame, ::Integer, ::Colon) at /Users/gerlacar/.julia/packages/DataFrames/S3ZFo/src/dataframerow/dataframerow.jl:92
getindex(::AbstractDataFrame, ::CartesianIndex{2}) at /Users/gerlacar/.julia/packages/DataFrames/S3ZFo/src/other/broadcasting.jl:3
I feel like I am entering a rabbit hole and that there has to be a better way to do this. Any suggestions? Thanks.