Teradata Package for Python Function Reference | 17.10 - filter - 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.filter = filter(self, items=None, like=None, regex=None, axis=1, **kw)
DESCRIPTION:
    Filter rows or columns of GeoDataFrame according to labels in the specified index.
    The filter is applied to the columns of the index when axis is set to 'rows'.
 
    Must use one of the parameters 'items', 'like', and 'regex' only.
 
PARAMETERS:
    axis:
        Optional Argument.
        Specifies the axis to filter on.
        1 denotes column axis (default). Alternatively, 'columns' can be specified.
        0 denotes row axis. Alternatively, 'rows' can be specified.
        Default Values: 1
        Permitted Values: 0, 1, 'rows', 'columns'
        Types: int OR str
 
    items:
        Optional Argument.
        List of values that the info axis should be restricted to.
        When axis is 1, items are a list of column names.
        When axis is 0, items are a list of literal values.
        Types: list of Strings (str) or literals
 
    like:
        Optional Argument.
        Specifies the substring pattern.
        When axis is 1, substring pattern for matching column names.
        When axis is 0, substring pattern for checking index values
        with REGEXP_SUBSTR.
        Types: str
 
    regex:
        Optional Argument.
        Specifies a regular expression pattern.
        When axis is 1, regex pattern for re.search(regex, column_name).
        When axis is 0, regex pattern for checking index values
        with REGEXP_SUBSTR.
        Types: str
 
    **kw: optional keyword arguments
 
        varchar_size:
            Specifies an integer to specify the size of varchar-casted index.
            Used when axis=0 or axis='rows' and index must be char-like in "like"
            and "regex" filtering.
            Default Value: configure.default_varchar_size
            Types: int
 
        match_arg: string
            Specifies argument to pass if axis is 0/'rows' and regex is used.
 
            Valid values for match_arg are:
            - 'i': case-insensitive matching.
            - 'c': case sensitive matching.
            - 'n': the period character (match any character) can match
                    the newline character.
            - 'm': index value is treated as multiple lines instead of as a single
                    line. With this option, the '^' and '$' characters apply to each
                    line in source_string instead of the entire index value.
            - 'l': if index value exceeds the current maximum allowed size
                    (currently 16 MB), a NULL is returned instead of an error.
                    This is useful for long-running queries where you do not want
                    long strings causing an error that would make the query fail.
            - 'x': ignore whitespace.
 
    The 'match_arg' argument may contain more than one character.
    If a character in 'match_arg' is not valid, then that character is ignored.
 
    See Teradata® Database SQL Functions, Operators, Expressions, and Predicates,
    for more information on specifying arguments for REGEXP_SUBSTR.
 
    NOTES:
        - Using 'regex' or 'like' with axis equal to 0 will attempt to cast the
          values in the index to a VARCHAR.
          Note that conversion between BYTE data and other types is not supported.
          Also, LOBs are not allowed to be compared.
 
        - When using 'like' or 'regex', datatypes are casted into VARCHAR.
          This may alter the format of the value in the column(s)
          and thus whether there is a match or not. The size of the VARCHAR may also
          play a role since the casted value is truncated if the size is not big enough.
          See varchar_size under **kw: optional keyword arguments.
 
RETURNS:
    teradataml GeoDataFrame
 
RAISES:
    ValueError if more than one parameter: 'items', 'like', or 'regex' is used.
    TeradataMlException if invalid argument values are given.
 
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)
    >>>
    # Retrieve non-geometry columns in df
    >>> df.filter(items = ['skey', 'street_name'])
          street_name
    skey
    1      Coast Blvd
    1     Main Street
    >>>
    # Retrieve geometry column and 'skey' in df
    >>> df.filter(items = ['skey', 'street_shape'])
                      street_shape
    skey
    1     LINESTRING (12 12,18 17)
    1     LINESTRING (2 2,3 2,4 1)
    >>>
    # Retrieve rows where index matches 1
    >>> df.filter(items = ['1'], axis = 0)
          street_name              street_shape
    skey
    1      Coast Blvd  LINESTRING (12 12,18 17)
    1     Main Street  LINESTRING (2 2,3 2,4 1)
    >>>