
The get() method in pandas is used to select columns from a dataframe. You can select a single column or multiple columns. When single column selected, the get method returns a series and when multiple columns are selected then it returns a dataframe.
Syntax –
dataframe.get(key)
key – the name of the column that you want to select.
Examples –
1 . Select a Single column –
Let’s read a dataset to work with
import pandas as pd
url="https://raw.githubusercontent.com/bprasad26/lwd/master/data/winequality-red.csv"
df = pd.read_csv(url)
df.head()

Let’s say that you want to select the alcohol column from the dataframe.
# get the alcohol column
df.get('alcohol')

2 . Select multiple columns –
To select multiple columns, just pass the name of the columns in a list.
# get alcohol and pH columns
df.get(['alcohol','pH'])
