Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

chaining functions with pipe pipe using not the first argument

In a pipe i want to use the result of previous steps as the second argument to a subsequent step.

In R i can use the result of the previous chain using . like so:

df %>% b(arg1b) %>% c(arg1c, .)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How to do this in python for example using pipe?

df.pipe(b, arg1b).pipe(c, arg1c, **)

syntax error

>Solution :

I’m not an active user of pandas, but this documentation page on pandas.DataFrame.pipe seems to cover your case

df.pipe(b, arg1b)
  .pipe((c, 'second_arg_name'), arg1c)

where 'second_arg_name' should be replaced with actual name of the second argument in function c

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading