Teradata Package for Python Function Reference | 20.00 - cos - 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.cos = cos()
- DESCRIPTION:
Function computes the cosine value of the values in column.
The cosine of an angle is the ratio of two sides of a right triangle.
The ratio is the length of the side adjacent to the angle divided by
the length of the hypotenuse.
The cosine of the values in a column returns values in radians in
the range -1 to 1, inclusive.
NOTES:
1. If the type of the column is not FLOAT, column values are converted to FLOAT
based on implicit type conversion rules. If the value cannot be converted, an
error is reported.
2. Unsupported column types:
a. BYTE or VARBYTE
b. LOBs (BLOB or CLOB)
c. CHARACTER or VARCHAR if the server character set is GRAPHIC
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: Calculates cosine value for the "gpa" column and pass it
# as input to DataFrame.assign().
>>> result = df.assign(col=df.gpa.cos())
>>> print(result)
masters gpa stats programming admitted col
id
3 no 3.70 Novice Beginner 1 -0.848100
4 yes 3.50 Beginner Novice 1 -0.936457
2 yes 3.76 Beginner Beginner 0 -0.814803
1 yes 3.95 Beginner Beginner 0 -0.690651
# Example 2: Filter the rows where cosine of values in "gpa" column
# are less than -0.70.
>>> print(df[df.gpa.cos() < -0.70])
masters gpa stats programming admitted
id
4 yes 3.50 Beginner Novice 1
3 no 3.70 Novice Beginner 1
2 yes 3.76 Beginner Beginner 0