Skip to content
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 for multiindex dataframe #36914

Closed
2 of 3 tasks
AgnesBaud opened this issue Oct 6, 2020 · 1 comment
Closed
2 of 3 tasks

BUG: groupby dropna for multiindex dataframe #36914

AgnesBaud opened this issue Oct 6, 2020 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@AgnesBaud
Copy link

  • I have checked that this issue has not already been reported.

  • 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.


Hello,

I'm not sure if it's a bug report, a feature request, or if there's already another way to do it. In which case, I would be happy to hear it and close this issue.

Code Sample, a copy-pastable example

import pandas as pd
import numpy as np

test_df = pd.DataFrame.from_dict({
'gene_1' : ['Bacteria', 'Lactobacillus', 11, 17],
'gene_2' : ['Bacteria', 'Lactobacillus', 9, 3],
'gene_3' : [np.nan, np.nan, 1, 2],
'gene_4' : [np.nan, np.nan, 3, 4],
'gene_5' : ['Bacteria', np.nan, 10, 11]
},
orient='index', columns=['kingdom', 'genus', 'sample_1', 'sample_2'])
test_df = test_df.set_index(['kingdom', 'genus'])

test_df

test_df.groupby(level=[0,1], dropna = False).sum()

Current output

groupby sum

Problem description

I would like the dropna option of groupby to handle multipleindex dataframe

Expected Output

whatiwant

Output of pd.show_versions()

INSTALLED VERSIONS

commit : db08276
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-48-generic
Version : #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.3
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 40.8.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 : 2.11.2
IPython : 7.18.1
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
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

Related issues : #3729 #29716

Thank you,

Agnès

@AgnesBaud AgnesBaud added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 6, 2020
@AgnesBaud
Copy link
Author

Sorry, my research by keywords didn't bring this issue up : #36470, which completely describe my problem.
Sorry again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant