grouped = s.groupby(s)

Or:

grouped = s.groupby(lambda x: s[x])
Answer from user1201614 on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.groupby.html
pandas.Series.groupby — pandas 3.0.2 documentation
Group Series using a mapper or by a Series of columns. A groupby operation involves some combination of splitting the object, applying a function, and combining the results.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.Series.groupby.html
pandas.Series.groupby — pandas 3.0.1 documentation
Group Series using a mapper or by a Series of columns. A groupby operation involves some combination of splitting the object, applying a function, and combining the results.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.core.groupby.SeriesGroupBy.aggregate.html
pandas.core.groupby.SeriesGroupBy.aggregate — pandas 2.3.3 documentation
>>> s = pd.Series([1, 2, 3, 4]) >>> s 0 1 1 2 2 3 3 4 dtype: int64 · >>> s.groupby([1, 1, 2, 2]).min() 1 1 2 3 dtype: int64 · >>> s.groupby([1, 1, 2, 2]).agg('min') 1 1 2 3 dtype: int64 · >>> s.groupby([1, 1, 2, 2]).agg(['min', 'max']) min max 1 1 2 2 3 4 ·
🌐
pandas
pandas.pydata.org › pandas-docs › dev › reference › api › pandas.Series.groupby.html
pandas.Series.groupby — pandas ain documentation
Group Series using a mapper or by a Series of columns. A groupby operation involves some combination of splitting the object, applying a function, and combining the results.
🌐
w3resource
w3resource.com › pandas › series › series-groupby.php
Pandas: Series - groupby() function - w3resource
The groupby() function involves some combination of splitting the object, applying a function, and combining the results. This can be used to group large amounts of data and compute operations on these groups ...
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-dataframe-groupby
Pandas dataframe.groupby() Method - GeeksforGeeks
In this example, we will demonstrate how to group data by a single column using the groupby method. We will work with NBA-dataset that contains information about NBA players, including their teams, points scored, and assists. We'll group the data by the Team column and calculate the total points scored for each team. ... import pandas as pd df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv") team = df.groupby('Team') print(team.first()) # Let's print the first entries in all the groups formed.
Published   July 11, 2025
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 1.5 › reference › api › pandas.Series.groupby.html
pandas.Series.groupby — pandas 1.5.2 documentation
Group Series using a mapper or by a Series of columns. A groupby operation involves some combination of splitting the object, applying a function, and combining the results.
Find elsewhere
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.core.groupby.SeriesGroupBy.count.html
pandas.core.groupby.SeriesGroupBy.count — pandas 2.3.3 documentation
Apply a function groupby to each row or column of a DataFrame. ... >>> lst = ['a', 'a', 'b'] >>> ser = pd.Series([1, 2, np.nan], index=lst) >>> ser a 1.0 a 2.0 b NaN dtype: float64 >>> ser.groupby(level=0).count() a 2 b 0 dtype: int64
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.core.groupby.SeriesGroupBy.mean.html
pandas.core.groupby.SeriesGroupBy.mean — pandas 2.3.3 documentation
pandas.Series or pandas.DataFrame · See also · Series.groupby · Apply a function groupby to a Series. DataFrame.groupby · Apply a function groupby to each row or column of a DataFrame. Examples · >>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2], ... 'B': [np.nan, 2, 3, 4, 5], ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.core.groupby.SeriesGroupBy.indices.html
pandas.core.groupby.SeriesGroupBy.indices — pandas 2.3.3 documentation
>>> lst = ['a', 'a', 'b'] >>> ser = pd.Series([1, 2, 3], index=lst) >>> ser a 1 a 2 b 3 dtype: int64 >>> ser.groupby(level=0).indices {'a': array([0, 1]), 'b': array([2])} For DataFrameGroupBy: >>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]] >>> df = pd.DataFrame(data, columns=["a", "b", "c"], ...
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas series groupby() function with examples
Pandas Series groupby() Function with Examples - Spark By {Examples}
March 27, 2024 - The groupby() function in the Pandas Series is a powerful tool for grouping data based on certain criteria. The groupby operation is used to split a
🌐
Pandas
pandas.pydata.org › docs › reference › groupby.html
GroupBy — pandas 3.0.2 documentation - PyData |
pandas.api.typing.DataFrameGroupBy and pandas.api.typing.SeriesGroupBy instances are returned by groupby calls pandas.DataFrame.groupby() and pandas.Series.groupby() respectively.
🌐
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.pandas › api › pyspark.pandas.Series.groupby.html
pyspark.pandas.Series.groupby — PySpark 4.1.1 documentation
Group DataFrame or Series using one or more columns. A groupby operation involves some combination of splitting the object, applying a function, and combining the results.
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 2.1 › reference › api › pandas.Series.groupby.html
pandas.Series.groupby — pandas 2.1.4 documentation
Group Series using a mapper or by a Series of columns. A groupby operation involves some combination of splitting the object, applying a function, and combining the results.
🌐
Real Python
realpython.com › pandas-groupby
pandas GroupBy: Your Guide to Grouping Data in Python – Real Python
January 19, 2025 - Since bool is technically just a specialized type of int, you can sum a Series of True and False just as you would sum a sequence of 1 and 0: ... The result is the number of mentions of "Fed" by the Los Angeles Times in the dataset. The same routine gets applied for Reuters, NASDAQ, Businessweek, and the rest of the lot. ... Now backtrack again to .groupby().apply() to see why this pattern can be suboptimal. To get some background information, check out How to Speed Up Your pandas Projects.
🌐
Beautiful Soup
tedboy.github.io › pandas › generated › pandas.Series.groupby.html
pandas.Series.groupby — Pandas Doc
Series.groupby(by=None, axis=0, level=None, as_index=True, sort=True, group_keys=True, squeeze=False, **kwargs)
🌐
IncludeHelp
includehelp.com › python › how-to-group-a-series-by-values-in-pandas.aspx
How to group a series by values in pandas?
September 25, 2023 - To group a series by values in pandas, we will use first convert the series into a dataframe, and then we will use pandas.DataFrame.groupby() method. This method is used to group the data inside DataFrame based on the condition passed inside it as a parameter.
🌐
Apache Software Foundation
archive.apache.org › dist › spark › docs › 3.4.4 › api › python › reference › pyspark.pandas › api › pyspark.pandas.Series.groupby.html
pyspark.pandas.Series.groupby — PySpark 3.4.4 documentation
Series.groupby(by: Union[Any, Tuple[Any, …], Series, List[Union[Any, Tuple[Any, …], Series]]], axis: Union[int, str] = 0, as_index: bool = True, dropna: bool = True) → SeriesGroupBy[source]¶