Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • O openpyxl
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 283
    • Issues 283
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • openpyxl
  • openpyxl
  • Issues
  • #1724
Closed
Open
Issue created Aug 21, 2021 by Yury Paykov@ojomio

dataframe_to_rows misses the level of multi-index

Name: openpyxl Version: 3.0.7

In []: df1 = pd.DataFrame({'a':[pd.NA, 'foo', 'one', pd.NA, 'one'],'b':['bar', 'yura', 'two', pd.NA, 'xuzzy']})

In []: df1
Out[]: 
      a      b
0  <NA>    bar
1   foo   yura
2   one    two
3  <NA>   <NA>
4   one  xuzzy

In []: df1.groupby(['a','b'], dropna=False).agg(count=('a', 'count'))
Out[]: 
           count
a   b           
foo yura       1
one two        1
    xuzzy      1
NaN bar        0
    NaN        0

In []: list(dataframe_to_rows(df1.groupby(['a','b'], dropna=False).agg(count=('a', 'count'))))
Out[]: 
[[None, None, 'count'],
 FrozenList(['a', 'b']),
 ['foo', 'yura', 1],
 [None, 'two', 1],
 [None, 'xuzzy', 1],
 [None, 'bar', 0],
 [None, nan, 0]]

As can be seen, "one" key in the first level of index is missing

Edited Aug 21, 2021 by Yury Paykov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking