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 · DataFrameGroupBy.__iter__()
Pandas
pandas.pydata.org › pandas-docs › stable › › reference › api › pandas.api.typing.DataFrameGroupBy.transform.html
pandas.api.typing.DataFrameGroupBy.transform — pandas 3.0.1 documentation
Call function producing a same-indexed DataFrame on each group · Returns a DataFrame having the same indexes as the original object filled with the transformed values
Videos
Pandas
pandas.pydata.org › docs › user_guide › groupby.html
Group by: split-apply-combine — pandas 3.0.1 documentation
On a DataFrame, we obtain a GroupBy object by calling groupby(). This method returns a pandas.api.typing.DataFrameGroupBy instance. We could naturally group by either the A or B columns, or both: In [7]: grouped = df.groupby("A") In [8]: grouped = df.groupby("B") In [9]: grouped = df.groupby(["A", ...
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.shift.html
pandas.api.typing.DataFrameGroupBy.shift — pandas 3.0.1 documentation
For DataFrameGroupBy: >>> data = [[1, 2, 3], [1, 5, 6], [2, 5, 8], [2, 6, 9]] >>> df = pd.DataFrame( ... data, ... columns=["a", "b", "c"], ... index=["tuna", "salmon", "catfish", "goldfish"], ... ) >>> df a b c tuna 1 2 3 salmon 1 5 6 catfish 2 5 8 goldfish 2 6 9 >>> df.groupby("a").shift(1) b c tuna NaN NaN salmon 2.0 3.0 catfish NaN NaN goldfish 5.0 8.0 ·
Pandas
pandas.pydata.org › docs › reference › api › pandas.api.typing.DataFrameGroupBy.aggregate.html
pandas.api.typing.DataFrameGroupBy.aggregate — pandas 3.0.1 documentation
The values are tuples whose first element is the column to select and the second element is the aggregation to apply to that column. Pandas provides the pandas.NamedAgg namedtuple with the fields ['column', 'aggfunc'] to make it clearer what the arguments are.
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.median.html
pandas.api.typing.DataFrameGroupBy.median — pandas 3.0.1 documentation
For DataFrameGroupBy: >>> data = {"a": [1, 3, 5, 7, 7, 8, 3], "b": [1, 4, 8, 4, 4, 2, 1]} >>> df = pd.DataFrame( ... data, index=["dog", "dog", "dog", "mouse", "mouse", "mouse", "mouse"] ... ) >>> df a b dog 1 1 dog 3 4 dog 5 8 mouse 7 4 mouse 7 4 mouse 8 2 mouse 3 1 >>> df.groupby(level=0).median() a b dog 3.0 4.0 mouse 7.0 3.0 ·
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.nth.html
pandas.api.typing.DataFrameGroupBy.nth — pandas 3.0.1 documentation
Take the nth row from each group if n is an int, otherwise a subset of rows · Can be either a call or an index. dropna is not available with index notation. Index notation accepts a comma separated list of integers and slices
Pandas
pandas.pydata.org › docs › reference › api › pandas.api.typing.DataFrameGroupBy.agg.html
pandas.api.typing.DataFrameGroupBy.agg — pandas 3.0.1 documentation
The values are tuples whose first element is the column to select and the second element is the aggregation to apply to that column. Pandas provides the pandas.NamedAgg namedtuple with the fields ['column', 'aggfunc'] to make it clearer what the arguments are.
Pandas
pandas.pydata.org › docs › reference › api › pandas.api.typing.DataFrameGroupBy.shift.html
pandas.api.typing.DataFrameGroupBy.shift — pandas documentation
For DataFrameGroupBy: >>> data = [[1, 2, 3], [1, 5, 6], [2, 5, 8], [2, 6, 9]] >>> df = pd.DataFrame( ... data, ... columns=["a", "b", "c"], ... index=["tuna", "salmon", "catfish", "goldfish"], ... ) >>> df a b c tuna 1 2 3 salmon 1 5 6 catfish 2 5 8 goldfish 2 6 9 >>> df.groupby("a").shift(1) b c tuna NaN NaN salmon 2.0 3.0 catfish NaN NaN goldfish 5.0 8.0 ·
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.prod.html
pandas.api.typing.DataFrameGroupBy.prod — pandas 3.0.1 documentation
For DataFrameGroupBy: >>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]] >>> df = pd.DataFrame( ... data, ... columns=["a", "b", "c"], ... index=["tiger", "leopard", "cheetah", "lion"], ... ) >>> df a b c tiger 1 8 2 leopard 1 2 5 cheetah 2 5 8 lion 2 6 9 >>> df.groupby("a").prod() b c a 1 16 10 2 30 72 ·
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.ffill.html
pandas.api.typing.DataFrameGroupBy.ffill — pandas 3.0.1 documentation
DataFrameGroupBy.ffill(limit=None)[source]# Forward fill the values. Parameters: limitint, optional · Limit of how many values to fill. Returns: Series or DataFrame · Object with missing values filled. See also · Series.ffill · Returns Series with minimum number of char in object.
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.ohlc.html
pandas.api.typing.DataFrameGroupBy.ohlc — pandas 3.0.1 documentation
DataFrameGroupBy.ohlc()[source]# Compute open, high, low and close values of a group, excluding missing values. For multiple groupings, the result index will be a MultiIndex · Returns: DataFrame · Open, high, low and close values within each group. See also · DataFrame.agg ·
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.groupby.html
pandas.DataFrame.groupby — pandas 3.0.2 documentation
pandas.api.typing.DataFrameGroupBy · Returns a groupby object that contains information about the groups. See also · resample · Convenience method for frequency conversion and resampling of time series. Notes · See the user guide for more detailed usage and examples, including splitting ...
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.first.html
pandas.api.typing.DataFrameGroupBy.first — pandas 3.0.1 documentation
DataFrameGroupBy.first(numeric_only=False, min_count=-1, skipna=True)[source]# Compute the first entry of each column within each group. Defaults to skipping NA elements. Parameters: numeric_onlybool, default False · Include only float, int, boolean columns.
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.aggregate.html
pandas.api.typing.DataFrameGroupBy.aggregate — pandas 3.0.0 documentation
The values are tuples whose first element is the column to select and the second element is the aggregation to apply to that column. Pandas provides the pandas.NamedAgg namedtuple with the fields ['column', 'aggfunc'] to make it clearer what the arguments are.
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.nunique.html
pandas.api.typing.DataFrameGroupBy.nunique — pandas 3.0.1 documentation
DataFrameGroupBy.nunique(dropna=True)[source]# Return DataFrame with counts of unique elements in each position. Parameters: dropnabool, default True · Don’t include NaN in the counts. Returns: nunique: DataFrame · Counts of unique elements in each position.
Pandas
pandas.pydata.org › docs › dev › reference › api › pandas.api.typing.DataFrameGroupBy.ewm.html
pandas.api.typing.DataFrameGroupBy.ewm — pandas 3.0.0rc1+28.g37421be5bc documentation
DataFrameGroupBy.ewm(com=None, span=None, halflife=None, alpha=None, min_periods=0, adjust=True, ignore_na=False, times=None, method='single')[source]#
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.typing.DataFrameGroupBy.size.html
pandas.api.typing.DataFrameGroupBy.size — pandas 3.0.1 documentation
DataFrameGroupBy.size()[source]# Compute group sizes. Returns: DataFrame or Series · Number of rows in each group as a Series if as_index is True or a DataFrame if as_index is False. See also · Series.size · Apply function size to a Series. DataFrame.size ·
Pandas
pandas.pydata.org › docs › dev › reference › api › pandas.api.typing.DataFrameGroupBy.expanding.html
pandas.api.typing.DataFrameGroupBy.expanding — pandas 3.0.0.dev0+2649.gead37b2db4 documentation
pandas.api.typing.ExpandingGroupby · An object that supports expanding transformations over each group. See also · Series.expanding · Expanding transformations for Series. DataFrame.expanding · Expanding transformations for DataFrames. Series.groupby · Apply a function groupby to a Series.
Pandas
pandas.pydata.org › docs › dev › reference › api › pandas.api.typing.DataFrameGroupBy.min.html
pandas.api.typing.DataFrameGroupBy.min - PyData |
The reference guide contains a detailed description of the pandas API. The reference describes how the methods work and which parameters can be used.