I have a Series like this after doing groupby(\'name\') and used mean() function on other column
name 383 3.000000 663 1.000000 726 1.000000 7
A fast way of doing this is to reconstruct using numpy to slice the underlying arrays. See timings below.
numpy
mask = s.values != 1 pd.Series(s.values[mask], s.index[mask]) 0 383 3.000000 737 9.000000 833 8.166667 dtype: float64
naive timing