Functional pipes in python like %>% from R's magritrr

后端 未结 14 2230
春和景丽
春和景丽 2020-11-29 16:17

In R (thanks to magritrr) you can now perform operations with a more functional piping syntax via %>%. This means that instead of coding this: <

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 16:50

    There is dfply module. You can find more information at

    https://github.com/kieferk/dfply

    Some examples are:

    from dfply import *
    diamonds >> group_by('cut') >> row_slice(5)
    diamonds >> distinct(X.color)
    diamonds >> filter_by(X.cut == 'Ideal', X.color == 'E', X.table < 55, X.price < 500)
    diamonds >> mutate(x_plus_y=X.x + X.y, y_div_z=(X.y / X.z)) >> select(columns_from('x')) >> head(3)
    

提交回复
热议问题