Teradata Package for Python Function Reference - 17.00 - groupby - 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
- teradataml.dataframe.dataframe.DataFrame.groupby = groupby(self, columns_expr)
- DESCRIPTION:
Apply 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)
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