Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - __neg__ - 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.sql.DataFrameColumn.__neg__ = __neg__(self)
Compute the unary negation of the ColumnExpressions using -.
 
PARAMETERS:
    None
 
RETURNS:
    _SQLColumnExpression
 
RAISES:
    Exception
        A TeradataMlException gets thrown if SQLAlchemy
        throws an exception when evaluating the expression
 
EXAMPLES:
    >>> load_example_data("dataframe", "admissions_train")
    >>> df = DataFrame("admissions_train")
    >>> df
       masters   gpa     stats programming  admitted
    id
    13      no  4.00  Advanced      Novice         1
    36      no  3.00  Advanced      Novice         0
    15     yes  4.00  Advanced    Advanced         1
    40     yes  3.95    Novice    Beginner         0
    22     yes  3.46    Novice    Beginner         0
    38     yes  2.65  Advanced    Beginner         1
    26     yes  3.57  Advanced    Advanced         1
    5       no  3.44    Novice      Novice         0
    7      yes  2.33    Novice      Novice         1
    19     yes  1.98  Advanced    Advanced         0
 
    # Example 1: Negate the values in the column 'gpa' and assign those
    #           values to new column 'negate_gpa'.
    >>> df.assign(negate_gpa=-df.gpa)
       masters   gpa     stats programming  admitted  negate_gpa
    id
    5       no  3.44    Novice      Novice         0       -3.44
    34     yes  3.85  Advanced    Beginner         0       -3.85
    13      no  4.00  Advanced      Novice         1       -4.00
    40     yes  3.95    Novice    Beginner         0       -3.95
    22     yes  3.46    Novice    Beginner         0       -3.46
    19     yes  1.98  Advanced    Advanced         0       -1.98
    36      no  3.00  Advanced      Novice         0       -3.00
    15     yes  4.00  Advanced    Advanced         1       -4.00
    7      yes  2.33    Novice      Novice         1       -2.33
    17      no  3.83  Advanced    Advanced         1       -3.83
 
    # Example 2: Filter out the rows by taking negation of gpa not equal to 3.44 or
    #            admitted equal to 1.
    >>> df[~((df.gpa != 3.44) | (df.admitted == 1))]
                 id masters   gpa   stats  admitted
    programming
    Novice        5      no  3.44  Novice         0