Top "Pandas-groupby" questions

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

Get statistics for each group (such as count, mean, etc) using pandas GroupBy?

I have a data frame df and I use several columns from it to groupby: df['col1','col2',…

python pandas dataframe group-by pandas-groupby
Converting a Pandas GroupBy output from Series to DataFrame

I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", "Mallory", "Bob" , "Mallory"] , "City" : ["Seattle", "Seattle", "…

python pandas dataframe pandas-groupby multi-index
Count unique values with pandas per groups

I need to count unique ID values in every domain I have data ID, domain 123, 'vk.com' 123, 'vk.com' 123, 'twitter.…

python pandas group-by unique pandas-groupby
Get the Row(s) which have the max count in groups using groupby

How do I find all rows in a pandas dataframe which have the max value for count column, after grouping …

python pandas max pandas-groupby
How to group dataframe rows into list in pandas groupby

I have a pandas data frame df like: a b A 1 A 2 B 5 B 5 B 4 C 6 I want to group …

python pandas list aggregate pandas-groupby
How to access pandas groupby dataframe by key

How do I access the corresponding groupby dataframe in a groupby object by the key? With the following groupby: rand = …

python pandas dataframe group-by pandas-groupby
pandas GroupBy columns with NaN (missing) values

I have a DataFrame with many missing values in columns which I wish to groupby: import pandas as pd import …

python pandas group-by pandas-groupby nan
pandas dataframe groupby datetime month

Consider a csv file: string,date,number a string,2/5/11 9:16am,1.0 a string,3/5/11 10:44pm,2.0 a string,4/22/11 12:07pm,3.0 a string,4/22/11 12:10pm,4.0 a …

python pandas datetime pandas-groupby
Renaming Column Names in Pandas Groupby function

Q1) I want to do a groupby, SQL-style aggregation and rename the output column: Example dataset: >>> df …

python pandas group-by pandas-groupby rename
GroupBy pandas DataFrame and select most common value

I have a data frame with three string columns. I know that the only one value in the 3rd column …

python pandas group-by pandas-groupby mode