We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ x] I have checked that this issue has not already been reported.
[x ] I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
df = pd.DataFrame({'a': [1,2,3]}) dtype = pd.api.types.CategoricalDtype([1,2]) df['b'] =df.a.astype(dtype) df.groupby('b',dropna=False).size()
observations for categorical variables with na values are dropped from groupby() even if dropna=False is specified.
b nan 1 1 1 2 1
b 1 1 2 1
pd.show_versions()
commit : 9d598a5 python : 3.9.0.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19041 machine : AMD64 processor : AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD byteorder : little LC_ALL : None LANG : en.UTF-8 LOCALE : English_United States.1252
pandas : 1.2.1 numpy : 1.19.5 pytz : 2020.5 dateutil : 2.8.1 pip : 20.3.1 setuptools : 50.3.2 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 2.11.2 IPython : 7.19.0 pandas_datareader: None bs4 : None bottleneck : None fsspec : None fastparquet : None gcsfs : None matplotlib : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 3.0.0 pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None numba : None
The text was updated successfully, but these errors were encountered:
Thanks for the report! This is a duplicate of #36327
Sorry, something went wrong.
No branches or pull requests
[ x] I have checked that this issue has not already been reported.
[x ] I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
df = pd.DataFrame({'a': [1,2,3]})
dtype = pd.api.types.CategoricalDtype([1,2])
df['b'] =df.a.astype(dtype)
df.groupby('b',dropna=False).size()
Problem description
observations for categorical variables with na values are dropped from groupby() even if dropna=False is specified.
Expected Output
b
nan 1
1 1
2 1
Actual output
b
1 1
2 1
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 9d598a5
python : 3.9.0.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : en.UTF-8
LOCALE : English_United States.1252
pandas : 1.2.1
numpy : 1.19.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.1
setuptools : 50.3.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 3.0.0
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: