pivot table but keep nan

Solutions on MaxInterview for pivot table but keep nan by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "pivot table but keep nan"
Amelie
06 Feb 2016
1(df.groupby(['Date', 'A']).B
2   .apply(lambda x: np.nan if x.isna().all() else x.sum())
3   .unstack('A')
4)