I need to use the transform function to sum column 'bar' when I group by column 'foo'. I use the following code df.groupby(['foo'])['bar'].transform(np.sum) However, when all the values in 'bar' are NaNs, my desired output is NaNs but the above code returns zero instead. How can I fix this? I know in the sum function I can use min_count = 1 but I am not sure how to use that in the above context. Continue reading...