Chain the transformation without @chain macro

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.

should be:

x.sleep_total

Thank you it works well. But please explain why it works. Is there any documentation for this behavior?

It is in documentation of filter:

the predicate fun is passed DataFrameRows. Elements of a DataFrameRow may be accessed with dot syntax or column indexing inside fun.

  julia> df = DataFrame(x=[3, 1, 2, 1], y=["b", "c", "a", "b"])
  4×2 DataFrame
   Row │ x      y
       │ Int64  String
  ─────┼───────────────
     1 │     3  b
     2 │     1  c
     3 │     2  a
     4 │     1  b

  julia> filter(row -> row.x > 1, df)
  2×2 DataFrame
   Row │ x      y
       │ Int64  String
  ─────┼───────────────
     1 │     3  b
     2 │     2  a

  julia> filter(row -> row["x"] > 1, df)
  2×2 DataFrame
   Row │ x      y
       │ Int64  String
  ─────┼───────────────
     1 │     3  b
     2 │     2  a

Perhaps with the use of the Pipe package you get something close to the desired chain transformation

using DataFrames
x = DataFrame(x=[3, 1, 1, 2], y=4:-1:1, z=1:4)
x[:,[:x]] |>x->filter(x->x.x>1,x)

using Pipe : @pipe

@pipe x |> select(_,[:x,:y]) |> filter(y->y.x>1,_)