pipe()
noun
say it: “PYP” /ˈpaɪp/
A pandas method that runs a function you wrote on the table and passes the result on, so your own steps fit into a chain of methods.
What does pipe() do in pandas?
pipe() calls a function you wrote, handing it the table at that point, and passes on whatever the function
returns. It lets your own cleaning steps sit in a method chain beside pandas' methods: df.pipe(drop_sentinels) is
the same as drop_sentinels(df).
clean = (
raw
.pipe(drop_sentinels) # your own function, given the table
.pipe(flag_impossible)
)
In a sentence
- “With pipe(), each of her cleaning functions became one line of the recipe.”
- “pipe() put the drop_sentinels function into the chain between rename and sort.”
Level: Freelancer · More Python terms at this level
Updated