Teradata Package for Python Function Reference | 17.10 - Pack - 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

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.sqle.Pack = class Pack(builtins.object)
     Methods defined here:
__init__(self, data=None, input_columns=None, output_column=None, delimiter=',', include_column_name=True, data_order_column=None)
DESCRIPTION:
    The Pack function packs data from multiple input columns into a 
    single column. The packed column has a virtual column for each input 
    column. By default, virtual columns are separated by commas and each 
    virtual column value is labeled with its column name.
 
    Note: This function is only available when teradataml is connected
          to Vantage 1.1 or later versions.
 
 
PARAMETERS:
     data:
        Required Argument.
        Specifies the teradataml DataFrame containing the input attributes.
        
    data_order_column:
        Optional Argument.
        Specifies Order By columns for data.
        Values to this argument can be provided as a list, if multiple 
        columns are used for ordering.
        Types: str OR list of Strings (str)
    
    input_columns:
        Optional Argument.
        Specifies the names of the input columns to pack into a single output 
        column. These names become the column names of the virtual columns. 
        By default, all input teradataml DataFrame columns are packed into a 
        single output column. If you specify this argument, but do not 
        specify all input teradataml DataFrame columns, the function copies 
        the unspecified input teradataml DataFrame columns to the output 
        teradataml DataFrame.
        Types: str OR list of Strings (str)
    
    output_column:
        Required Argument.
        Specifies the name to give to the packed output column.
        Types: str
    
    delimiter:
        Optional Argument.
        Specifies the delimiter (a string) that separates the virtual columns 
        in the packed data.
        Default Value: ","
        Types: str
    
    include_column_name:
        Optional Argument.
        Specifies whether to label each virtual column value with its column 
        name (making the virtual column "input_column:value"). 
        Default Value: True
        Types: bool
 
RETURNS:
    Instance of Pack.
    Output teradataml DataFrames can be accessed using attribute 
    references, such as PackObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load the data to run the example.
    load_example_data("Pack", "ville_temperature")
    
    # Create teradataml DataFrame objects.
    # The input, ville_temperature contains temperature readings for the 
    # cities Nashville and Knoxville, in the state of Tennessee.
    ville_temperature = DataFrame.from_table("ville_temperature")
 
    # Example1 - Default Argument Values.
    # Default values used for arguments "delimiter" and "include_column_name".
    pack_out1 = Pack(data=ville_temperature,
                    input_columns=['city','state','period','temp_f'],
                    output_column='packed_data',
                    delimiter=',',
                    include_column_name=True)
    
    # Print the results
    print(pack_out1.result)
    
    # Example2 - Nondefault Argument Values.
    # This example uses nondefault values for arguments "delimiter" and "include_column_name".
    pack_out2 = Pack(data=ville_temperature,
                    input_columns=['city','state','period','temp_f'],
                    output_column='packed_data',
                    delimiter='|',
                    include_column_name=False)
    
    # Print the results
    print(pack_out2)
__repr__(self)
Returns the string representation for a Pack class instance.
get_build_time(self)
Function to return the build time of the algorithm in seconds.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
get_prediction_type(self)
Function to return the Prediction type of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
get_target_column(self)
Function to return the Target Column of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
show_query(self)
Function to return the underlying SQL query.
When model object is created using retrieve_model(), then None is returned.