Question: If I calculate the mean of a groupby object and within one of the groups there is a NaN(s) the NaNs are ignored. Even when applying np.mean it is still returning just the mean of all valid numbers. I would expect a behaviour of returning NaN as soon as one NaN is within the group. Here a simplified example of the behaviour

```
import pandas as pd
import numpy as np
c = pd.DataFrame({'a':[1,np.nan,2,3],'b':[1,2,1,2]})
c.groupby('b').mean()
     a
b     
1  1.5
2  3.0
c.groupby('b').agg(np.mean)
     a
b     
1  1.5
2  3.0

```

I want to receive following result:

```
     a
b     
1  1.5
2  NaN

```

I am aware that I can replace NaNs beforehand and that i probably can write my own aggregation function to return NaN as soon as NaN is within the group. This function wouldn't be optimized though. 

Do you know of an argument to achieve the desired behaviour with the optimized functions?

Btw, I think the desired behaviour was implemented in a previous version of pandas.

Answer: 
There is `mean(skipna=False)`, but it's not working
===================================================

GroupBy aggregation methods (min, max, mean, median, etc.) have the `skipna` parameter, which is meant for this exact task, but it seems that currently (may-2020) there is a [bug](https://github.com/pandas-dev/pandas/issues/32696) (issue opened on mar-2020), which prevents it from working correctly.

Quick workaround
================

Complete working example based on this comments: [@Serge Ballesta](https://stackoverflow.com/a/54106817/7204581), [@RoelAdriaans](https://stackoverflow.com/questions/54106112/pandas-groupby-mean-not-ignoring-nans/54106520#comment104906560_54106817)

```py
>>> import pandas as pd
>>> import numpy as np
>>> c = pd.DataFrame({'a':[1,np.nan,2,3],'b':[1,2,1,2]})
>>> c.fillna(np.inf).groupby('b').mean().replace(np.inf, np.nan)

     a
b     
1  1.5
2  NaN

```

For additional information and updates follow the link above.
Use the `skipna` option - 

```
c.groupby('b').apply(lambda g: g.mean(skipna=False))

```