Skip to content

groupby on single column fails #142

@gtklocker

Description

@gtklocker

Describe the bug
Running the example code from this page results in an error.

To Reproduce
Steps to reproduce the behavior:

  1. Create a minimal html file with these contents:
<!doctype html>
<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/danfojs@0.2.3/lib/bundle.min.js"></script>
  </head>
  <body>
    <script>
      let data ={'A': ['foo', 'bar', 'foo', 'bar',
                      'foo', 'bar', 'foo', 'foo'],
                 'B': ['one', 'one', 'two', 'three',
                      'two', 'two', 'one', 'three'],
                 'C': [1,3,2,4,5,2,6,7],
                 'D': [3,2,4,1,5,6,7,8]
              }
      
      let df = new dfd.DataFrame(data)
      
      let grp = df.groupby(["A"])
      grp.col(["C"]).cumsum().head().print()
      grp.col(["C"]).cumsum().tail().print()
    </script>
  </body>
</html>
  1. Open in a browser
  2. Open the console log
  3. See error:
    Uncaught TypeError: Cannot read property 'undefined' of undefined
    at eval (eval at arithemetic (bundle.min.js:6), :1:21)
    at GroupBy.arithemetic (bundle.min.js:6)
    at GroupBy.value (bundle.min.js:6)
    at test.html:19

Expected behavior
No error.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Chrome
  • Version: 88.0.4324.192

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions