Вы можете использовать groupby
без расстановки, как, например,
import pandas as pd
ix = pd.MultiIndex(
levels=[['2018-05', '2018-06'], [1, 2, 3, 4, 5, 6, 7]],
labels=[[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1],
[0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6]],
names=['job_date', 'branch_id'])
series = pd.Series(
[0.618980, 0.600590, 0.603486, 0.043931, 0.588168, 0.381518,
0.357035, 0.690575, 0.700900, 0.571556, 0.351935, 0.626428,
0.461813, 0.329663],
index=ix)
series.groupby(by='branch_id').diff()
Выход:
job_date branch_id
2018-05 1 nan
2 nan
3 nan
4 nan
5 nan
6 nan
7 nan
2018-06 1 0.07160
2 0.10031
3 -0.03193
4 0.30800
5 0.03826
6 0.08029
7 -0.02737
dtype: float64