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
Index | Species | Color | Weight | Age |
---|---|---|---|---|
0 | dog | black | 40 | 5 |
1 | cat | golden | 15 | 8 |
2 | cat | black | 20 | 9 |
3 | dog | white | 80 | 2 |
4 | dog | black | 25 | 0.5 |
5 | hamster | black | 1 | 3 |
6 | hamster | golden | 0.25 | 0.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'])
Index | Species |
---|---|
0 | dog |
1 | cat |
2 | cat |
3 | dog |
4 | dog |
5 | hamster |
6 | hamster |
7 | cat |
pets.get(['Species', 'Color'])
Index | Species | Color |
---|---|---|
0 | dog | black |
1 | cat | golden |
2 | cat | black |
3 | dog | white |
4 | dog | black |
5 | hamster | black |
6 | hamster | golden |
7 | cat | black |