Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - index - 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.index
DESCRIPTION:
    Returns the index_label of the teradataml DataFrame.
 
RETURNS:
    str or List of Strings (str) representing the index_label of the DataFrame.
 
RAISES:
    None
 
EXAMPLES:
    >>> load_example_data("dataframe","admissions_train")
    >>> df = DataFrame("admissions_train")
    >>> df
       masters   gpa     stats programming  admitted
    id
    5       no  3.44    Novice      Novice         0
    3       no  3.70    Novice    Beginner         1
    1      yes  3.95  Beginner    Beginner         0
    20     yes  3.90  Advanced    Advanced         1
    8       no  3.60  Beginner    Advanced         1
    25      no  3.96  Advanced    Advanced         1
    18     yes  3.81  Advanced    Advanced         1
    24      no  1.87  Advanced      Novice         1
    26     yes  3.57  Advanced    Advanced         1
    38     yes  2.65  Advanced    Beginner         1
 
    >>> # Get the index_label
    >>> df.index
    ['id']
 
    >>> # Set new index_label
    >>> df = df.set_index(['id', 'masters'])
    >>> df
                 gpa     stats programming  admitted
    id masters
    5  no       3.44    Novice      Novice         0
    3  no       3.70    Novice    Beginner         1
    1  yes      3.95  Beginner    Beginner         0
    17 no       3.83  Advanced    Advanced         1
    13 no       4.00  Advanced      Novice         1
    32 yes      3.46  Advanced    Beginner         0
    11 no       3.13  Advanced    Advanced         1
    9  no       3.82  Advanced    Advanced         1
    34 yes      3.85  Advanced    Beginner         0
    24 no       1.87  Advanced      Novice         1
 
    >>> # Get the index_label
    >>> df.index
    ['id', 'masters']