Q:

pivot table but keep nan

(df.groupby(['Date', 'A']).B
   .apply(lambda x: np.nan if x.isna().all() else x.sum())
   .unstack('A')
)
0

New to Communities?

Join the community