Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - squeeze - 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.geospatial.geodataframe.GeoDataFrame.squeeze = squeeze(self, axis=None)
DESCRIPTION:
    Squeeze one-dimensional axis objects into scalars.
    teradataml GeoDataFrames with a single element are squeezed to a scalar.
    teradataml GeoDataFrames with a single column are squeezed to a Series.
    Otherwise the object is unchanged.
 
    Note: Currently only '1' and 'None' are supported for axis.
          For now with axis = 0, the teradataml GeoDataFrame is returned.
 
PARAMETERS:
    axis:
        Optional Argument.
        A specific axis to squeeze. By default, all axes with
        length equals one are squeezed.
        Permitted Values: 0 or 'index', 1 or 'columns', None
        Default: None
 
RETURNS:
    teradataml GeoDataFrame, teradataml Series, or scalar,
    the projection after squeezing 'axis' or all the axes.
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    >>> load_example_data("geodataframe","sample_streets")
    >>> gdf = GeoDataFrame("sample_streets")
    >>> gdf
          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: Squeeze the GeoDataFrame.
    >>> shape = gdf.select(["street_shape"])
    >>> shape.squeeze()
    0    LINESTRING (12 12,18 17)
    1    LINESTRING (2 2,3 2,4 1)
    Name: street_shape, dtype: object
    >>>
 
    >>> shape.squeeze(axis = 1)
    0    LINESTRING (12 12,18 17)
    1    LINESTRING (2 2,3 2,4 1)
    Name: street_shape, dtype: object
    >>>
 
    >>> shape.squeeze(axis = 0)
                   street_shape
    0  LINESTRING (12 12,18 17)
    1  LINESTRING (2 2,3 2,4 1)
    >>>
 
    # Example 2: Squeeze the GeoDataFrame created from a query.
    >>> df = GeoDataFrame.from_query('select skey, street_shape from sample_streets')
    >>> s = df.squeeze()
    >>> s
                      street_shape
    skey
    1     LINESTRING (12 12,18 17)
    1     LINESTRING (2 2,3 2,4 1)
    >>>
 
    # Example 3: Squeeze the GeoDataFrame containing only one value.
    >>> gdf_single = gdf[gdf.street_name == "Coast Blvd"].select("street_shape")
    >>> gdf_single
                   street_shape
    0  LINESTRING (12 12,18 17)
    >>> gdf_single.squeeze()
    'LINESTRING (12 12,18 17)'
    >>> gdf_single.squeeze(axis = 1)
    0    LINESTRING (12 12,18 17)
    Name: street_shape, dtype: object
    >>> gdf_single.squeeze(axis = 0)
                   street_shape
    0  LINESTRING (12 12,18 17)
    >>>