“Piping” output from one function to another using Python infix syntax

前端 未结 5 810
-上瘾入骨i
-上瘾入骨i 2020-12-14 02:17

I\'m trying to replicate, roughly, the dplyr package from R using Python/Pandas (as a learning exercise). Something I\'m stuck on is the \"piping\" functionality.

In

5条回答
  •  悲&欢浪女
    2020-12-14 02:47

    You can use sspipe library, and use the following syntax:

    from sspipe import p
    df = df | p(select, 'one') \
            | p(rename, one = 'new_one')
    

提交回复
热议问题