Skip to content

dataframe.groupby incorrect with multiindex and None value #32492

@ataudt

Description

@ataudt

Minimally reproducible example

# pandas==0.24.2
df = pd.DataFrame(data={
    'A': ['a1','a2',None],
    'B': ['b1','b2','b1'],
    'val': [1,2,3],
})
print(df)
print('\n')

grps = df.groupby(['A', 'B'])
print(grps.get_group(('a2','b1')))

Problem description

Selecting a group which doesn't appear, I obtain a group which should not exist.

Expected Output

KeyError

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.24.2
pytest: None
pip: 19.0.3
setuptools: 40.8.0
Cython: None
numpy: 1.16.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.4.0
sphinx: 2.0.1
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.3
openpyxl: None
xlrd: 1.2.0
xlwt: None
xlsxwriter: 1.1.7
lxml.etree: 4.3.3
bs4: None
html5lib: 1.0.1
sqlalchemy: 1.3.8
pymysql: 0.9.3
psycopg2: 2.8.3 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions