Hey regarding groupby operations in pandas. I have been moving more and more (for too complicated groupbys) to running them something like:
out_rec = []
for id, group in data_frame.groupby("id"):
ladidida....
result = f(group)
out_rec.append(result)
in my experience it isn't much slower than a groupby.apply.