Tutorials References Exercises Sign Up Menu
Create Website Get Certified Pro

Pandas DataFrame get() Method

❮ DataFrame Reference


Extract the "firstname" column from the DataFrame:

import pandas as pd

data = {
  "firstname": ["Sally", "Mary", "John"],
  "age": [50, 40, 30],
  "qualified": [True, False, False]

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

Definition and Usage

The get() method returns the specified column(s) from the DataFrame.

If you specify only one column, the return value is a Pandas Series object.

To specify more than one column, specify the columns inside an array. The result will be a new DataFrame object.




Parameter Description
key  Optional. A String or object representing the column(s) you want to return

Return Value

If only one column is returned: a Pandas Series object.

If more than one column are returned: a Pandas DataFrame object.

❮ DataFrame Reference