Tutorials References Exercises Sign Up Menu
Create Website Get Certified Pro

Pandas DataFrame pipe() Method

❮ DataFrame Reference


Apply a function to the DataFrame that will overwrite the "age" column:

import pandas as pd

def change_age(x):
  x["age"]=[10, 20, 30]
  return x

data = {
  "name": ["Sally", "Mary", "John"],
  "age": [50, 40, 30]

df = pd.DataFrame(data)
Try it Yourself »

Definition and Usage

The pipe() method allows you to apply one or more functions to the DataFrame object.


dataframe.pipe(func, args, kwargs)


Parameter Description
func Required. A function to apply to the DataFrame.
args Optional, An iterable object with positional arguments that can be used in the function
kwargs Optional. A dictionary with keyword arguments that can be used in the function

Return Value

A DataFrame object.

This function makes changes to the original DataFrame object.

❮ DataFrame Reference