Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - get - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
17.20
Publication Date
November 2022
Content Type
Programming Reference
Publication ID
B700-4500-112K
ft:locale
en-US
ft:lastEdition
2024-02-21
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_1720
Product Category
Teradata Vantage
teradataml.dataframe.dataframe.DataFrame.get = get(self, key)
DESCRIPTION:
    Retrieve required columns from DataFrame using column name(s) as key.
    Returns a new teradataml DataFrame with requested columns only.
 
PARAMETERS:
 
    key:
        Required Argument.
        Specifies column(s) to retrieve from the teradataml DataFrame.
        Types: str OR List of Strings (str)
 
    teradataml supports the following formats (only) for the "get" method:
 
    1] Single Column String: df.get("col1")
    2] Single Column List: df.get(["col1"])
    3] Multi-Column List: df.get(['col1', 'col2', 'col3'])
    4] Multi-Column List of List: df.get([["col1", "col2", "col3"]])
 
    Note: Multi-Column retrieval of the same column such as df.get(['col1', 'col1']) is not supported.
 
RETURNS:
    teradataml DataFrame
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    >>> load_example_data("dataframe","admissions_train")
    >>> df = DataFrame("admissions_train")
    >>> df.sort('id')
       masters   gpa     stats programming admitted
    id
    1      yes  3.95  Beginner    Beginner        0
    2      yes  3.76  Beginner    Beginner        0
    3       no  3.70    Novice    Beginner        1
    4      yes  3.50  Beginner      Novice        1
    ...
 
    1] Single String Column
    >>> df.get("gpa")
        gpa
    0  3.46
    1  3.52
    2  3.68
    3  3.65
    ...
 
    2] Single Column List
    >>> df.get(["gpa"])
        gpa
    0  3.46
    1  3.52
    2  3.68
    3  3.65
    ...
 
    3] Multi-Column List
    >>> df.get(["programming", "masters", "gpa"])
      programming masters   gpa
    0    Beginner     yes  3.46
    1      Novice      no  3.52
    2    Beginner      no  3.68
    3      Novice      no  3.65
    ...
 
    4] Multi-Column List of List
    >>> df.get([['programming', 'masters', 'gpa']])
      programming masters   gpa
    0    Advanced     yes  4.00
    1    Advanced     yes  3.45
    2    Beginner     yes  3.50
    3    Beginner     yes  4.00
    ...