Top "Pandas-groupby" questions

To be used for grouping variables together based on a given condition.

How do I create a new column from the output of pandas groupby().sum()?

Trying to create a new column from the groupby calculation. In the code below, I get the correct calculated values …

python pandas group-by pandas-groupby
Concatenate strings from several rows using Pandas groupby

I want to merge several strings in a dataframe based on a groupedby in Pandas. This is my code so …

python-3.x pandas pandas-groupby
Group dataframe and get sum AND count?

I have a dataframe that looks like this: Company Name Organisation Name Amount 10118 Vifor Pharma UK Ltd Welsh Assoc for …

python pandas dataframe group-by pandas-groupby
Multiple aggregations of the same column using pandas GroupBy.agg()

Is there a pandas built-in way to apply two different aggregating functions f1, f2 to the same column df["returns"], …

python pandas dataframe aggregate pandas-groupby
Groupby value counts on the dataframe pandas

I have the following dataframe: df = pd.DataFrame([ (1, 1, 'term1'), (1, 2, 'term2'), (1, 1, 'term1'), (1, 1, 'term2'), (2, 2, 'term3'), (2, 3, 'term1'), (2, 2, …

python pandas dataframe crosstab pandas-groupby
Python Pandas Group by date using datetime data

I have a column Date_Time that I wish to groupby date time without creating a new column. Is this …

python pandas datetime dataframe pandas-groupby
Pandas - dataframe groupby - how to get sum of multiple columns

This should be an easy one, but somehow I couldn't find a solution that works. I have a pandas dataframe …

python pandas dataframe pandas-groupby
Python - rolling functions for GroupBy object

I have a time series object grouped of the type <pandas.core.groupby.SeriesGroupBy object at 0x03F1A9…

python pandas pandas-groupby rolling-computation rolling-sum
Pandas: filling missing values by mean in each group

This should be straightforward, but the closest thing I've found is this post: pandas: Filling missing values within a group, …

python pandas pandas-groupby imputation fillna
Keep other columns when doing groupby

I'm using groupby on a pandas dataframe to drop all rows that don't have the minimum of a specific column. …

python pandas aggregate pandas-groupby