“Piping” output from one function to another using Python infix syntax
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 R/dplyr, this is done using the pipe-operator %>% , where x %>% f(y) is equivalent to f(x, y) . If possible, I would like to replicate this using infix syntax (see here ). To illustrate, consider the two functions below. import pandas as pd def select(df, *args): cols = [x for x in args] df = df[cols] return df def rename(df, **kwargs): for name, value in kwargs.items(): df = df.rename(columns={'%s' % name: '%s' % value}) return df