| |
- Overlap(data1, columns1, gen_sql_only=False, **kwargs)
- DESCRIPTION:
The function performs Overlap analysis by combining information from multiple
DataFrames into an analytic data set by providing counts of overlapping key
fields among pairs of DataFrames. For example, if an analytic data set is being
built to describe customers, it is useful to know whether the customer, account,
and transaction tables that provide information about customers refer to the
same customers.
Given teradataml DataFrames and corresponding column names, the Overlap analysis
determines the number of instances of that column which each pair-wise combination
of DataFrames has in common. The same can also be performed for multiple columns
taken together.
Overlap analysis is used to process any data type that is comparable except those
containing byte data.
PARAMETERS:
data1:
Required Argument.
Specifies the input DataFrame containing the columns on which Overlap analysis
is to be performed.
Types: teradataml DataFrame
columns1:
Required Argument.
Specifies the name(s) of the column(s), in "data1" argument, to be used in
Overlap analysis.
Types: str OR list of Strings (str)
gen_sql_only:
Optional Argument.
Specifies whether to generate only SQL for the function.
When set to True, function SQL is generated, not executed, which can be accessed
using show_query() method, otherwise SQL is just executed but not returned.
Default Value: False
Types: bool
kwargs:
Specifies the additional data and columns arguments that can be used with
"data1" and "columns1" for Overlap analysis.
data2, ..., dataN:
Optional Arguments.
Specifies the additional input DataFrames containing the columns on which
Overlap analysis is to be performed along with "data1" and "columns1".
Types: list of teradataml DataFrames
columns2, ..., columnsN:
Optional Arguments.
Specifies the name(s) of the columns(s) of additional input DataFrames to be
used in the Overlap analysis along with "data1" and "columns1".
Types: str OR list of Strings (str)
Notes:
1.The data and columns related arguments must be in a sequence starting from
"data2" and "columns2" respectively.
2.For each data argument (datai), corresponding columns argument (columnsi)
must be specified and vice-versa.
3.The number of columns in each of the columns related arguments (including
"columns1" argument) should be same.
RETURNS:
An instance of Overlap.
Output teradataml DataFrames can be accessed using attribute references, such as
OverlapObj.<attribute_name>.
Output teradataml DataFrame attribute name is: result.
RAISES:
TeradataMlException, TypeError, ValueError
EXAMPLES:
# 1. To execute Vantage Analytic Library functions,
# a. import "valib" object from teradataml.
# b. set 'configure.val_install_location' to the database name where Vantage
# analytic library functions are installed.
# 2. Datasets used in these examples can be loaded using Vantage Analytic Library
# installer.
# Import valib object from teradataml to execute this function.
from teradataml import valib
# Set the 'configure.val_install_location' variable.
from teradataml import configure
configure.val_install_location = "SYSLIB"
# Create required teradataml DataFrame.
customer = DataFrame("customer")
customer_analysis = DataFrame("customer_analysis")
checking_tran = DataFrame("checking_tran")
credit_tran = DataFrame("credit_tran")
savings_tran = DataFrame("savings_tran")
# Example 1: Run Overlap analysis on "cust_id" column present in the DataFrames
# 'customer' and 'customer_analysis'.
overlap_obj = valib.Overlap(data1=customer,
data2=customer_analysis,
columns1=["cust_id"],
columns2="cust_id")
# Print the results.
print(overlap_obj.result)
# Example 2: Run Overlap analysis on columns "cust_id" and "tran_id" present in
# the DataFrames 'checking_tran', 'credit_tran' and 'savings_tran'.
overlap_obj = valib.Overlap(data1=checking_tran,
data2=credit_tran,
data3=savings_tran,
columns1=["cust_id", "tran_id"],
columns2=["cust_id", "tran_id"],
columns3=["cust_id", "tran_id"])
# Print the results.
print(overlap_obj.result)
# Example 3: Generate only SQL for the function, but do not execute the same.
obj = valib.Overlap(data1=customer,
data2=customer_analysis,
columns1=["cust_id"],
columns2="cust_id",
gen_sql_only=True)
# Print the generated SQL.
print(obj.show_query("sql"))
# Print both generated SQL and stored procedure call.
print(obj.show_query("both"))
# Print the stored procedure call.
print(obj.show_query())
print(obj.show_query("sp"))
|