groupby().first() skips NaN values · Issue #6732 · pandas-dev/pandas (original) (raw)
>>> df = pd.DataFrame([[1,np.nan,0],[1,1,1],[2,2,2],[2,3,3]], columns=list('abc'))
>>> print(df)
a b c
0 1 NaN 0
1 1 1 1
2 2 2 2
3 2 3 3
[4 rows x 3 columns]
>>> print(df.groupby('a').first())
b c
a
1 1 0
2 2 2
[2 rows x 2 columns]
>>> print(df.groupby('a').first())
b c
a
1 NaN 0
2 2 2
[2 rows x 2 columns]
Is it possible to achieve my expected output? I get the same output in master and 0.13.1.