Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - iloc - 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.iloc
Access a group of rows and columns by integer values or a boolean array.
VALID INPUTS:
    - A single integer values, e.g. 5.
 
    - A list or array of integer values, e.g. ``[1, 2, 3]``.
 
    - A slice object with integer values, e.g. ``1:6``.
      Note: The stop value is excluded.
 
    - A boolean array of the same length as the column axis for column access,
 
    Note: For integer indexing on row access, the integer index values are
    applied to a sorted teradataml DataFrame on the index column or the first column if
    there is no index column.
 
RETURNS:
    teradataml DataFrame
 
RAISE:
    TeradataMlException
 
EXAMPLES
--------
    >>> load_example_data("dataframe","sales")
    >>> df = DataFrame('sales')
    >>> df
                Feb   Jan   Mar   Apr    datetime
    accounts
    Blue Inc     90.0    50    95   101  04/01/2017
    Alpha Co    210.0   200   215   250  04/01/2017
    Jones LLC   200.0   150   140   180  04/01/2017
    Yellow Inc   90.0  None  None  None  04/01/2017
    Orange Inc  210.0  None  None   250  04/01/2017
    Red Inc     200.0   150   140  None  04/01/2017
 
    # Retrieve row using a single integer.
    >>> df.iloc[1]
            Feb Jan Mar  Apr    datetime
    accounts
    Blue Inc  90.0  50  95  101  04/01/2017
 
    # List of integers. Note using ``[[]]``
    >>> df.iloc[[1, 2]]
                Feb  Jan  Mar  Apr    datetime
    accounts
    Blue Inc    90.0   50   95  101  04/01/2017
    Jones LLC  200.0  150  140  180  04/01/2017
 
    # Single integer for row and column
    >>> df.iloc[5, 0]
    Empty DataFrame
    Columns: []
    Index: [Yellow Inc]
 
    # Single integer for row and column
    >>> df.iloc[5, 1]
        Feb
    0  90.0
 
    # Single integer for row and column access using a tuple
    >>> df.iloc[(5, 1)]
        Feb
    0  90.0
 
    # Slice for row and single integer for column access. As mentioned
    # above, note the stop for the slice is excluded.
    >>> df.iloc[2:5, 0]
    Empty DataFrame
    Columns: []
    Index: [Orange Inc, Jones LLC, Red Inc]
 
    # Slice for row and a single integer for column access. As mentioned
    # above, note the stop for the slice is excluded.
    >>> df.iloc[2:5, 2]
        Jan
    0  None
    1   150
    2   150
 
    # Slice for row and column access. As mentioned
    # above, note the stop for the slice is excluded.
    >>> df.iloc[2:5, 0:5]
                Mar   Jan    Feb   Apr
    accounts
    Orange Inc  None  None  210.0   250
    Red Inc      140   150  200.0  None
    Jones LLC    140   150  200.0   180
 
    # Empty slice for row and column access.
    >>> df.iloc[:, :]
                  Feb   Jan   Mar   Apr    datetime
    accounts
    Blue Inc     90.0    50    95   101  04/01/2017
    Alpha Co    210.0   200   215   250  04/01/2017
    Jones LLC   200.0   150   140   180  04/01/2017
    Yellow Inc   90.0  None  None  None  04/01/2017
    Orange Inc  210.0  None  None   250  04/01/2017
    Red Inc     200.0   150   140  None  04/01/2017
 
    # List of integers and boolean array for column access
    >>> df.iloc[[0, 2, 3, 4], [True, True, False, False, True, True]]
                  Feb   Apr    datetime
    accounts
    Orange Inc  210.0   250  04/01/2017
    Red Inc     200.0  None  04/01/2017
    Jones LLC   200.0   180  04/01/2017
    Alpha Co    210.0   250  04/01/2017