Teradata Package for Python Function Reference on VantageCloud Lake - groupby - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
20.00.00.04
Published
March 2025
ft:locale
en-US
ft:lastEdition
2025-04-11
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
teradataml.dataframe.dataframe.DataFrame.groupby = groupby(self, columns_expr, **kwargs)
DESCRIPTION:
    Applies GroupBy to one or more columns of a teradataml Dataframe.
    The result will always behaves like calling groupby with as_index=False
    in pandas.
 
PARAMETERS:
    columns_expr:
        Required Argument.
        Specifies the column name(s) to group by.
        Types: str OR list of Strings (str)
 
    kwargs:
        Optional Argument.
        Specifies keyword arguments.
 
        option:
            Optional Argument.
            Specifies the groupby option.
            Permitted Values: "CUBE", "ROLLUP", None
            Types: str or NoneType
 
NOTES:
    1. Users can still apply teradataml DataFrame methods (filters/sort/etc) on top of the result.
    2. Consecutive operations of grouping, i.e., groupby_time(), resample() and groupby() are not permitted.
       An exception will be raised. Following are some cases where exception will be raised as
       "Invalid operation applied, check documentation for correct usage."
            a. df.resample().groupby()
            b. df.resample().resample()
            c. df.resample().groupby_time()
 
RETURNS:
    teradataml DataFrameGroupBy Object
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    >>> load_example_data("dataframe","admissions_train")
    >>> df = DataFrame("admissions_train")
    >>> df1 = df.groupby(["masters"])
    >>> df1.min()
      masters min_id  min_gpa min_stats min_programming min_admitted
    0      no      3     1.87  Advanced        Advanced            0
    1     yes      1     1.98  Advanced        Advanced            0