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.dataframe.dataframe.DataFrame.squeeze = squeeze(self, axis=None)
DESCRIPTION:
    Squeeze one-dimensional axis objects into scalars.
    teradataml DataFrames with a single element are squeezed to a scalar.
    teradataml DataFrames 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 DataFrame 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 DataFrame, teradataml Series, or scalar,
    the projection after squeezing 'axis' or all the axes.
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    >>> load_example_data("dataframe", "admissions_train")
    >>> df = DataFrame("admissions_train")
    >>> df
       masters   gpa     stats programming admitted
    id
    22     yes  3.46    Novice    Beginner        0
    36      no  3.00  Advanced      Novice        0
    15     yes  4.00  Advanced    Advanced        1
    38     yes  2.65  Advanced    Beginner        1
    5       no  3.44    Novice      Novice        0
    17      no  3.83  Advanced    Advanced        1
    34     yes  3.85  Advanced    Beginner        0
    13      no  4.00  Advanced      Novice        1
    26     yes  3.57  Advanced    Advanced        1
    19     yes  1.98  Advanced    Advanced        0
 
    >>> gpa = df.select(["gpa"])
    >>> gpa.squeeze()
    0    4.00
    1    2.33
    2    3.46
    3    3.83
    4    4.00
    5    2.65
    6    3.57
    7    3.44
    8    3.85
    9    3.95
    Name: gpa, dtype: float64
    >>> gpa.squeeze(axis = 1)
    0    3.46
    1    3.00
    2    4.00
    3    2.65
    4    3.44
    5    3.83
    6    3.85
    7    4.00
    8    3.57
    9    1.98
    Name: gpa, dtype: float64
    >>> gpa.squeeze(axis = 0)
        gpa
    0  3.46
    1  3.00
    2  4.00
    3  2.65
    4  3.44
    5  3.83
    6  3.85
    7  4.00
    8  3.57
    9  1.98
 
    >>> df = DataFrame.from_query('select gpa, stats from admissions_train where gpa=2.33')
    >>> s = df.squeeze()
    >>> s
        gpa   stats
    0  2.33  Novice
 
    >>> single_gpa = DataFrame.from_query('select gpa from admissions_train where gpa=2.33')
    >>> single_gpa
        gpa
    0  2.33
    >>> single_gpa.squeeze()
    2.33
    >>> single_gpa.squeeze(axis = 1)
    0    2.33
    Name: gpa, dtype: float64
    >>> single_gpa.squeeze(axis = 0)
        gpa
    0  2.33