pyspark.pandas.groupby.GroupBy.get_group¶
-
GroupBy.
get_group
(name: Union[Any, Tuple[Any, …], List[Union[Any, Tuple[Any, …]]]]) → FrameLike[source]¶ Construct DataFrame from group with provided name.
- Parameters
- nameobject
The name of the group to get as a DataFrame.
- Returns
- groupsame type as obj
Examples
>>> psdf = ps.DataFrame([('falcon', 'bird', 389.0), ... ('parrot', 'bird', 24.0), ... ('lion', 'mammal', 80.5), ... ('monkey', 'mammal', np.nan)], ... columns=['name', 'class', 'max_speed'], ... index=[0, 2, 3, 1]) >>> psdf name class max_speed 0 falcon bird 389.0 2 parrot bird 24.0 3 lion mammal 80.5 1 monkey mammal NaN
>>> psdf.groupby("class").get_group("bird").sort_index() name class max_speed 0 falcon bird 389.0 2 parrot bird 24.0
>>> psdf.groupby("class").get_group("mammal").sort_index() name class max_speed 1 monkey mammal NaN 3 lion mammal 80.5