Description
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
import numpy as np
data = [
[1, 2, 3],
[4, np.nan, 6],
[7, 8, 9],
[10, 11, 12]
]
cols = ['a', 'b', 'c']
df = pd.DataFrame(data=data, columns=cols)
groupby_cols = ['a', 'b']
group_keys = df.groupby(groupby_cols, dropna=True).groups.keys()
Issue Description
group_keys
contains NA values even though the dropna
parameter is set to True
.
dict_keys([(1, 2.0), (4, nan), (7, 8.0), (10, 11.0)])
Expected Behavior
Expected values for group_keys
:
dict_keys([(1, 2.0), (7, 8.0), (10, 11.0)])
Installed Versions
INSTALLED VERSIONS
commit : 2a953cf
python : 3.10.11.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22623
machine : AMD64
processor : AMD64 Family 23 Model 8 Stepping 2, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.1.3
numpy : 1.26.1
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.0
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.17.2
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None