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

Fix bug in groupby checking wrong colDtype #398

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

igonro
Copy link
Contributor

@igonro igonro commented Feb 23, 2022

Closes #396

  • Write test that would fail in src/danfojs-browser/tests/aggregators/groupby.test.js
  • Write test that would fail in src/danfojs-node/test/aggregators/groupby.test.ts
  • Modify src/danfojs-base/aggregators/groupby.ts and src/danfojs-base/core/frame.ts to fix the issue
  • Run the tests again and check that the tests passed

Feel free to modify the code or add comments with the changes if you think something could be improved.

Thanks!

Copy link
Member

@steveoni steveoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@steveoni steveoni merged commit 5d8bd2d into javascriptdata:dev Feb 23, 2022
@@ -262,7 +262,8 @@ export default class Groupby {
let colName = groupColNames[colKey]
let colIndex = this.columnName.indexOf(colName)
let colDtype = this.colDtype[colIndex]
if (colDtype === "string") throw new Error(`Can't perform math operation on column ${colName}`)
let operationVal = (typeof operation === "string") ? operation : operation[colName]
if (colDtype === "string" && operationVal !== "count") throw new Error(`Can't perform math operation on column ${colName}`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! This will fix a problem I ran into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Groupby behaves differently depending on the order of the columns
3 participants