New issue
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
BUG: groupby(..., dropna=False).filter() never includes rows with NaNs in the index #44517
Comments
Hello! I would like to work on this issue. If we look at the pandas/pandas/core/groupby/generic.py Line 567 in 945c9ed
We can see that dropna function argument is set to True by default.pandas/pandas/core/groupby/generic.py Line 619 in 945c9ed
Then _apply_filter function gets called passing the indices and dropna arguments
There might be a problem in pandas/pandas/core/groupby/groupby.py Lines 1476 to 1490 in 945c9ed
@mroeschke what do you think? |
Sounds reasonable. May also want to investigate if the group |
@abatomunkuev I am also checking the |
It seems the problem comes from pandas/pandas/core/groupby/groupby.py Lines 617 to 666 in a3702e2
In the last line,
if the name contains For the above example, |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
When using
groupby()
and then applying a filter, if the group values include aNaN
, those rows are always dropped! If you adddropna=False
to thefilter
call, it just fills them with NaNs.Expected Behavior
NaN
s should be treated as unique values rather than dropped automatically.Installed Versions
INSTALLED VERSIONS
commit : 945c9ed
python : 3.9.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.14.16-arch1-1
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.4
numpy : 1.21.4
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 58.3.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
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 : None
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: