Top "Pandas-groupby" questions

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

Use Pandas groupby() + apply() with arguments

I would like to use df.groupby() in combination with apply() to apply a function to each row per group. …

python pandas dataframe apply pandas-groupby
How to get number of groups in a groupby object in pandas?

This would be useful so I know how many unique groups I have to perform calculations on. Thank you. Suppose …

python pandas dataframe group-by pandas-groupby
What is the equivalent of SQL "GROUP BY HAVING" on Pandas?

what would be the most efficient way to use groupby and in parallel apply a filter in pandas? Basically I …

python pandas pandas-groupby
Bar graph from dataframe groupby

import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.read_csv("arrests.csv") df = …

python pandas ggplot2 pandas-groupby
Pandas groupby with bin counts

I have a DataFrame that looks like this: +----------+---------+-------+ | username | post_id | views | +----------+---------+-------+ | john | 1 | 3 | | john | 2 | 23 | | …

python pandas dataframe pandas-groupby
How to pivot a dataframe?

What is pivot? How do I pivot? Is this a pivot? Long format to wide format? I've seen a lot …

python pandas group-by pivot pandas-groupby
Pandas number rows within group in increasing order

Given the following data frame: import pandas as pd import numpy as np df=pd.DataFrame({'A':['A','A','A',…

python-3.x pandas group-by pandas-groupby rank
Pandas groupby to to_csv

Want to output a Pandas groupby dataframe to CSV. Tried various StackOverflow solutions but they have not worked. Python 3.6.1, Pandas 0.20.1 …

python pandas csv pandas-groupby
pandas group by year, rank by sales column, in a dataframe with duplicate data

I would like to create a rank on year (so in year 2012, Manager B is 1. In 2011, Manager B is 1 again). …

python pandas duplicates pandas-groupby rank
Sample each group after pandas groupby

I know this must have been answered some where but I just could not find it. Problem: Sample each group …

python pandas random group-by pandas-groupby