Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pivot table but keep nan

(df.groupby(['Date', 'A']).B
   .apply(lambda x: np.nan if x.isna().all() else x.sum())
   .unstack('A')
)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pivot #table #nan
ADD COMMENT
Topic
Name
1+6 =