Teradata Package for Python Function Reference | 20.00 - mod - 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 - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00.00.03
Published
December 2024
Language
English (United States)
Last Update
2024-12-19
dita:id
TeradataPython_FxRef_Enterprise_2000
Product Category
Teradata Vantage
teradataml.dataframe.sql.DataFrameColumn.mod = mod(expression)
DESCRIPTION:
    Function returns the remainder (modulus) of the value in column
    divided by divisor (expression or constant).
 
ALTERNATE NAME:
    pmod
 
PARAMETERS:
    expression:
        Required Argument.
        Specifies a ColumnExpression of a numeric column or a constant value that is the divisor.
        Format for the argument: '<dataframe>.<dataframe_column>'.
        Types: ColumnExpression, int
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    DataFrameColumn
 
EXAMPLES:
    # Load the data to execute the example.
    >>> load_example_data("dataframe", "admissions_train")
 
    # Create a DataFrame on 'admissions_train' table.
    >>> df = DataFrame("admissions_train").iloc[:4]
    >>> print(df)
       masters   gpa     stats programming  admitted
    id
    3       no  3.70    Novice    Beginner         1
    4      yes  3.50  Beginner      Novice         1
    2      yes  3.76  Beginner    Beginner         0
    1      yes  3.95  Beginner    Beginner         0
 
    # Example 1: Compute the modulus of "gpa" column with constant and "gpa" column
    #            with "id" column, and pass it as input to DataFrame.assign().
    >>> res = df.assign(col = df.gpa.mod(2),
    ...                 col_id =  df.gpa.mod(df.id))
    >>> print(res)
       masters   gpa     stats programming  admitted   col  col_id
    id
    3       no  3.70    Novice    Beginner         1  1.70    0.70
    4      yes  3.50  Beginner      Novice         1  1.50    3.50
    2      yes  3.76  Beginner    Beginner         0  1.76    1.76
    1      yes  3.95  Beginner    Beginner         0  1.95    0.95
 
    # Example 2: Executed mod() function on "gpa" column and filtered computed
    #            values which are equal to 1.5.
    >>> print(df[df.gpa.mod(2) == 1.5])
       masters  gpa     stats programming  admitted
    id
    4      yes  3.5  Beginner      Novice         1