Teradata Python Package Function Reference - td_minus - Teradata Python Package - Look here for syntax, methods and examples for the functions included in the Teradata Python Package.
Teradata® Python Package Function Reference
- Product
- Teradata Python Package
- Release Number
- 16.20
- Published
- February 2020
- Language
- English (United States)
- Last Update
- 2020-07-17
- lifecycle
- previous
- Product Category
- Teradata Vantage
- teradataml.dataframe.setop.td_minus = td_minus(df_list, allow_duplicates=True)
- DESCRIPTION:
This function returns the resulting rows that appear in first teradataml DataFrame
and not in other teradataml DataFrames along the index axis.
PARAMETERS:
df_list:
Required argument.
Specifies the list of teradataml DataFrames on which the minus operation is to be performed.
Types: list of teradataml DataFrames
allow_duplicates:
Optional argument.
Specifies if the result of minus operation can have duplicate rows.
Default value: True
Types: bool
RETURNS:
teradataml DataFrame
RAISES:
TeradataMlException, TypeError
EXAMPLES:
>>> from teradataml import load_example_data
>>> load_example_data("dataframe", "setop_test1")
>>> load_example_data("dataframe", "setop_test2")
>>> from teradataml.dataframe.setop import td_minus
>>>
>>> df1 = DataFrame('setop_test1')
>>> df1
masters gpa stats programming admitted
id
62 no 3.70 Advanced Advanced 1
53 yes 3.50 Beginner Novice 1
69 no 3.96 Advanced Advanced 1
61 yes 4.00 Advanced Advanced 1
58 no 3.13 Advanced Advanced 1
51 yes 3.76 Beginner Beginner 0
68 no 1.87 Advanced Novice 1
66 no 3.87 Novice Beginner 1
60 no 4.00 Advanced Novice 1
59 no 3.65 Novice Novice 1
>>> df2 = DataFrame('setop_test2')
>>> df2
masters gpa stats programming admitted
id
12 no 3.65 Novice Novice 1
15 yes 4.00 Advanced Advanced 1
14 yes 3.45 Advanced Advanced 0
20 yes 3.90 Advanced Advanced 1
18 yes 3.81 Advanced Advanced 1
17 no 3.83 Advanced Advanced 1
13 no 4.00 Advanced Novice 1
11 no 3.13 Advanced Advanced 1
60 no 4.00 Advanced Novice 1
19 yes 1.98 Advanced Advanced 0
>>> idf = td_minus([df1[df1.id<55] , df2])
>>> idf
masters gpa stats programming admitted
id
51 yes 3.76 Beginner Beginner 0
50 yes 3.95 Beginner Beginner 0
54 yes 3.50 Beginner Advanced 1
52 no 3.70 Novice Beginner 1
53 yes 3.50 Beginner Novice 1
53 yes 3.50 Beginner Novice 1
>>>
>>> idf = td_minus([df1[df1.id<55] , df2], allow_duplicates=False)
>>> idf
masters gpa stats programming admitted
id
54 yes 3.50 Beginner Advanced 1
51 yes 3.76 Beginner Beginner 0
53 yes 3.50 Beginner Novice 1
50 yes 3.95 Beginner Beginner 0
52 no 3.70 Novice Beginner 1
>>> # applying minus on more than two DataFrames
>>> df3 = df1[df1.gpa <= 3.9]
>>> idf = td_minus([df1, df2, df3])
>>> idf
masters gpa stats programming admitted
id
61 yes 4.00 Advanced Advanced 1
50 yes 3.95 Beginner Beginner 0
69 no 3.96 Advanced Advanced 1