Teradata Package for Python Function Reference | 17.10 - groupby - 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
- Product Category
- Teradata Vantage
- teradataml.geospatial.geodataframe.GeoDataFrame.groupby = groupby(self, columns_expr)
- DESCRIPTION:
Applies GroupBy to one or more columns of a teradataml GeoDataFrame.
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 GeoDataFrame 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 GeoDataFrameGroupBy Object
RAISES:
TeradataMlException
EXAMPLES:
>>> load_example_data("geodataframe","sample_streets")
>>> df = GeoDataFrame("sample_streets")
>>> df1 = df.groupby(["street_shape"])
>>> df1.count()
street_shape count_skey count_street_name
0 LINESTRING (2 2,3 2,4 1) 1 1
1 LINESTRING (12 12,18 17) 1 1
>>>