Teradata Package for Python Function Reference | 17.10 - select - 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
- Product
- Teradata Package for Python
- Release Number
- 17.10
- Published
- April 2022
- Language
- English (United States)
- Last Update
- 2022-08-19
- lifecycle
- previous
- Product Category
- Teradata Vantage
- teradataml.geospatial.geodataframe.GeoDataFrame.select = select(self, select_expression)
- DESCRIPTION:
Select required columns from GeoDataFrame using an expression.
Returns a new teradataml GeoDataFrame with selected columns only.
PARAMETERS:
select_expression:
Required Argument.
String or List representing columns to select.
Types: str OR List of Strings (str)
The following formats (only) are supported for select_expression:
A] Single Column String: df.select("col1")
B] Single Column List: df.select(["col1"])
C] Multi-Column List: df.select(['col1', 'col2', 'col3'])
D] Multi-Column List of List: df.select([["col1", "col2", "col3"]])
Column Names ("col1", "col2"..) are Strings representing Teradata Vantage table Columns.
All Standard Teradata data types for columns supported: INTEGER, VARCHAR(5), FLOAT.
Note: Multi-Column selection of the same column such as df.select(['col1', 'col1']) is not supported.
RETURNS:
teradataml GeoDataFrame
RAISES:
TeradataMlException (TDMLDF_SELECT_INVALID_COLUMN, TDMLDF_SELECT_INVALID_FORMAT,
TDMLDF_SELECT_DF_FAIL, TDMLDF_SELECT_EXPR_UNSPECIFIED,
TDMLDF_SELECT_NONE_OR_EMPTY)
EXAMPLES:
>>> load_example_data("geodataframe","sample_streets")
>>> df = GeoDataFrame('sample_streets')
>>> df
street_name street_shape
skey
1 Coast Blvd LINESTRING (12 12,18 17)
1 Main Street LINESTRING (2 2,3 2,4 1)
>>>
# Example 1: Column passed as single String Column
>>> df.select("skey")
Empty DataFrame
Columns: []
Index: [1, 1]
>>>
# Example 2: Column passed as single Column List
>>> df.select(["street_shape"])
street_shape
0 LINESTRING (12 12,18 17)
1 LINESTRING (2 2,3 2,4 1)
>>>
# Example 3: Columns passed as multi-Column List
>>> df.select(["skey", "street_shape"])
street_shape
skey
1 LINESTRING (12 12,18 17)
1 LINESTRING (2 2,3 2,4 1)
>>>
# Example 4: Column passed as multi-Column List of List
>>> df.select([["skey", "street_shape"]])
street_shape
skey
1 LINESTRING (12 12,18 17)
1 LINESTRING (2 2,3 2,4 1)
>>>