Skip to main content

df.get()

df.get(column_name) or df.get([col_1_name, ..., col_k_name])

Returns column(s) from DataFrame.

Returns:
Series or DataFrame with the corresponding key(s).
Return Type:
Series or DataFrame
Note:
Can return a DataFrame with one column by putting the column name in square brackets.

pets
IndexIDSpeciesColorWeightAgeIs_CatOwner_Comment
0dog_001dogblack405False There are no bad dogs, only bad owners.
1cat_001catgolden1.50.2TrueMy best birthday present ever!!!
2cat_002catblack159True****All you need is love and a cat.****
3dog_002dogwhite802FalseLove is a wet nose and a wagging tail.
4dog_003dogblack250.5FalseBe the person your dog thinks you are.
5ham_001hamsterblack13FalseNo, thank you!
6ham_002hamstergolden0.250.2FalseNo, thank you!
7cat_003catblack100TrueNo, thank you!
pets.get('Species')
  • 0"dog"
  • 1"cat"
  • 2"cat"
  • 3"dog"
  • 4"dog"
  • 5"hamster"
  • 6"hamster"
  • 7"cat"


Get a series as a DataFrame.

pets.get(['Species'])
IndexSpecies
0dog
1cat
2cat
3dog
4dog
5hamster
6hamster
7cat
pets.get(['Species', 'Color'])
IndexSpeciesColor
0dogblack
1catgolden
2catblack
3dogwhite
4dogblack
5hamsterblack
6hamstergolden
7catblack

Problems or suggestions about this page? Fill out our feedback form.