Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - __getitem__ - 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
Docs.GeospatialDocs.GeoDataFrameInheritedDocumentation.GeoDataFrame.__getitem__ = __getitem__(self, key)
Return a column from the GeoDataFrame or filter the GeoDataFrame using an expression
or select columns from a GeoDataFrame using the specified list of columns.
The following operators are supported:
    comparison: ==, !=, <, <=, >, >=
    boolean: & (and), | (or), ~ (not), ^ (xor)
 
Operands can be Python literals and instances of ColumnExpressions from the GeoDataFrame.
 
PARAMETERS:
    key:
        Required Argument.
        Specifies the column name(s) of filter expression (ColumnExpression).
        Specify key as:
            * a string - to get the column of a teradataml GeoDataFrame, i.e., a ColumnExpression.
            * list of strings - to select columns of a teradataml GeoDataFrame.
            * filter expression - to filter the data from teradataml GeoDataFrame using the specified expression.
        Types: str or list of strings or ColumnExpression
 
RETURNS:
    GeoDataFrame or ColumnExpression instance
 
RAISES:
    1. KeyError   - If key is not found
    2. ValueError - When columns of different GeoDataFrames are given in ColumnExpression.
 
EXAMPLES:
    # Load the example data.
    load_example_data("geodataframe", ["sample_shapes"])
    
    # Create teradataml DataFrame object.
    gdf = DataFrame('sample_shapes')
 
    # Filter the GeoDataFrame gdf.
    gdf[gdf.points > gdf.linestrings]
    
    # Import GeometryType classes.
    from teradataml import Point, LineString, Polygon
 
    gdf[gdf.points > Point(1, 3, 5)]
    gdf[gdf.linestrings == LineString([(1, 3), (3, 0), (0, 1)])]
 
    p1 = Polygon([(0.6, 0.8), (0.6, 20.8), (20.6, 20.8), (20.6, 0.8), (0.6, 0.8)])
    gdf[p1 != gdf.polygons]
    gdf[~(p1 < gdf.polygons)]
 
    gdf[(gdf.polygons < p1) & (gdf.geom_collections != None)]
 
    # Retrieve column geosequence from gdf.
    gdf["geosequence"]
 
    # Select columns using list of column names from a teradataml GeoDataFrame.
    gdf[["points", "linestrings", "polygons"]]