Teradata Package for Python Function Reference - Statistics - 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.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage
 
 
Statistics

 
Functions
       
Statistics(data, columns=None, exclude_columns=None, extended_options='none', group_columns=None, statistical_method='population', stats_options=None, filter=None)
DESCRIPTION:
    Statistics analysis provides several common and not so common statistical measures
    for numeric data columns. Extended options include additional analyses and measures
    such as Values, Modes, Quantiles, and Ranks. Use statistical measures to understand
    the characteristics and properties of each numeric column, and to look for outlying
    values and anomalies.
 
    Statistics analysis can be performed on columns of numeric or date data type. For
    columns of type DATE, statistics other than count, minimum, maximum, and mean are
    calculated by first converting to the number of days since 1900.
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the input data to perform Statistics analysis.
        Types: teradataml DataFrame
 
    columns:
        Required Argument.
        Specifies the name(s) of the column(s) to analyze. Occasionally, it can also
        accept permitted strings to specify all columns, or all numeric columns, or
        all numeric and date columns.
        Permitted Values:
            * Name(s) of the column(s) in "data".
            * Pre-defined strings:
                * 'all' - all columns
                * 'allnumeric' - all numeric columns
                * 'allnumericanddate' - all numeric and date columns
        Types: str OR list of Strings (str)
 
    exclude_columns:
        Optional Argument.
        Specifies the name(s) of the column(s) to exclude from the analysis, if a
        column specifier such as 'all', 'allnumeric', 'allnumericanddate' is used
        in the "columns" argument.
        Types: str OR list of Strings (str)
 
    extended_options:
        Optional Argument.
        Specifies the extended options for calculating statistics.
        Permitted Values: 'all', 'none', 'modes', 'quantiles', 'values', 'rank'
        Default Value: 'none'
        Types: str OR list of Strings (str)
 
    group_columns:
        Optional Argument.
        Specifies the name(s) of column(s) to perform separate analysis for each group.
        Types: str OR list of Strings (str)
 
    statistical_method:
        Optional Argument.
        Specifies the statistical method.
        Permitted Values: 'sample', 'population'
        Default Value: 'population'
        Types: str
 
    stats_options:
        Optional Argument.
        Specifies the basic statistics to be calculated.
        Permitted Values:
            * all
            * count (cnt)
            * minimum (min)
            * maximum (max)
            * mean
            * standarddeviation (std)
            * skewness (skew)
            * kurtosis (kurt)
            * standarderror (ste)
            * coefficientofvariance (cv)
            * variance (var)
            * sum
            * uncorrectedsumofsquares (uss)
            * correctedsumofsquares (css)
        Default Value: ['cnt', 'min', 'max', 'mean', 'std']
        Types: str OR list of Strings (str)
 
    filter:
        Optional Argument.
        Specifies the clause to filter rows selected for analysis within Statistics.
        For example,
            filter = "cust_id > 0"
        Types: str
 
RETURNS:
    An instance of Statistics.
    Output teradataml DataFrames can be accessed using attribute references, such as
    StatisticsObj.<attribute_name>.
    Output teradataml DataFrame attribute name is: result.
 
RAISES:
    TeradataMlException, TypeError, ValueError
 
EXAMPLES:
    # Notes:
    #   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.
    df = DataFrame("customer")
    print(df)
 
    # Example 1: Perform Statistics analysis using default values on 'income' column.
    obj = valib.Statistics(data=df, columns="income")
 
    # Print the results.
    print(obj.result)
 
    # Example 2: Perform Statistics analysis on 'income' column with values grouped
    #            by 'gender' and only for rows with income greater than 0.
    obj = valib.Statistics(data=df,
                           columns="income",
                           group_columns="gender",
                           filter="income > 0")
 
    # Print the results.
    print(obj.result)
 
    # Example 3: Perform Statistics analysis requesting all statistical measures
    #            and extended options.
    obj = valib.Statistics(data=df,
                           columns="income",
                           stats_options="all",
                           extended_options="all")
 
    # Print the results.
    print(obj.result)
 
    # Example 4: Perform Statistics analysis requesting specific statistical measures
    #            and extended options and return sample statistics.
    obj = valib.Statistics(data=df,
                           columns="income",
                           stats_options=["cnt", "max", "min", "'mean",
                                          "css", "uss", "kurt", "skew"],
                           extended_options=["modes", "rank"],
                           statistical_method="sample")
 
    # Print the results.
    print(obj.result)