Skip to content

BUG: Inconsistent behavior of Groupby with None values with filter #62501

@chiiyeh

Description

@chiiyeh

Pandas version checks

  • 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 main branch of pandas.

Reproducible Example

import pandas as pd

df = pd.DataFrame(data=[
    {"a": 1, "b": None},
    {"a": 2, "b": None},
])
df.groupby("b", dropna=False).filter(lambda x: True)

Issue Description

Expected to return the full df, but it returns an empty df instead. Also inconsistent behavior when the first row, b col is changed to a number e.g. 10 (The row with None value is not returned) vs when it is changed to a string e.g. "a" (The row with None value is returned)

Expected Behavior

Expect it to return the full dataframe but it returns an empty df instead.

Installed Versions

INSTALLED VERSIONS ------------------ commit : 4665c10 python : 3.10.12 python-bits : 64 OS : Linux OS-release : 5.4.0-1154-azure-fips Version : #161+fips1-Ubuntu SMP Fri Jun 27 04:05:20 UTC 2025 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8

pandas : 2.3.2
numpy : 1.24.4
pytz : 2022.1
dateutil : 2.8.2
pip : 22.2.2
Cython : 0.29.32
sphinx : None
IPython : 8.10.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None
/databricks/python/lib/python3.10/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFilterse.g. head, tail, nthGroupbyMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions