Reading the DataFramesMeta.jl document helps me learn a clean way to chain the transformation with the @chain macro.
From its document:
@chain msleep begin
@select :name :sleep_total
@rsubset :sleep_total > 16
end
I wonder whether I can achieve the same with |>
operator so I try:
mammals_sleep[:, [:name, :sleep_total]] |> x -> filter(x -> x[!, :sleep_total] >= 10, x)
and get error
MethodError: no method matching getindex(::DataFrames.DataFrameRow{DataFrames.DataFrame, DataFrames.Index}, ::typeof(!), ::Symbol)
Closest candidates are:
getindex(::DataFrames.DataFrameRow, !Matched::Colon) at C:\Users\sofia\.julia\packages\DataFrames\LteEl\src\dataframerow\dataframerow.jl:225
getindex(::DataFrames.DataFrameRow, !Matched::Union{Colon, Regex, AbstractVector, DataAPI.All, DataAPI.Between, DataAPI.Cols, InvertedIndices.InvertedIndex}) at C:\Users\sofia\.julia\packages\DataFrames\LteEl\src\dataframerow\dataframerow.jl:215
getindex(::DataFrames.DataFrameRow, !Matched::Union{AbstractString, Signed, Symbol, Unsigned}) at C:\Users\sofia\.julia\packages\DataFrames\LteEl\src\dataframerow\dataframerow.jl:212
I know that @chain
macro is a more convenient and intuitive way to do but I also wanted to experiment and learn a new syntax system from Julia, where Julia did great job. Thanks.