Description
Code Sample, a copy-pastable example if possible
import pandas as pd
df = pd.DataFrame.from_dict({
'id': ['a'],
'value': [None]
})
df_grouped = df.groupby('id', as_index=False).first()
print(df)
print(df_grouped)
Output:
id value
0 a None
id value
0 a NaN
Problem description
Since at least version 1.0.2, the type of df_grouped
is NaN
. In Version 0.25.3, the type was None
.
This breaks my code since I later check for this value using if var is None
, which is False when var
is NaN
instead of None
.
Expected Output
id value
0 a None
id value
0 a None
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.8.1.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-88-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.2
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.0.0
Cython : None
pytest : 5.4.1
hypothesis : None
sphinx : 2.4.4
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.2.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.4.1
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.15
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None