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
IndexSpeciesColorWeightAge
0dogblack405
1catgolden158
2catblack209
3dogwhite802
4dogblack250.5
5hamsterblack13
6hamstergolden0.250.2
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