Questions tagged [bodo]

3 questions
87
votes
8 answers

Parallelize apply after pandas groupby

I have used rosetta.parallel.pandas_easy to parallelize apply after groupby, for example: from rosetta.parallel.pandas_easy import groupby_to_series_to_frame df = pd.DataFrame({'a': [6, 2, 2], 'b': [4, 5, 6]},index= ['g1', 'g1',…
Ivan
  • 2,871
  • 3
  • 16
  • 19
6
votes
3 answers

pandas: groupby apply using numba

Using pandas v1.1.0. In the pandas docs there is a nice example on how to use numba to speed up a rolling.apply() operation here import pandas as pd import numpy as np def mad(x): return np.fabs(x - x.mean()).mean() df = pd.DataFrame({"A":…
Ray Bell
  • 1,508
  • 4
  • 18
  • 45
2
votes
3 answers

Speeding up group-wise differencing in Pandas

Consider the following solution to computing a within-group diff in Pandas: df = df.set_index(['ticker', 'date']).sort_index()[['value']] df['diff'] = np.nan idx = pd.IndexSlice for ix in df.index.levels[0]: df.loc[ idx[ix,:], 'diff'] =…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564