-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Groupby
behaves differently depending on the order of the columns
#396
Comments
After having debugged the code a bit, I think maybe I have been able to find the error. In
When stopped at this line in the example that returns the error we have: colKey = 0 // the variable being iterated in the for loop
colName = "hours" // the name of the column in the current iteration
colIndex = 0 // the index of the column in the current iteration
this.colDtype = ["string"] // this refers to the Dtype of the groupby column ("day" or "worker" in my example) so when we execute I don't understand why we need to check if the I will do more debug in order to fully understand the problem, but since I can't program in Typescript is a little bit hard for me. thanks. |
Thanks for taking out time to submit this issue. @steveoni Can you take a look. |
Hi @risenW and @steveoni, thanks for your quick response! I was trying to write some tests and contribute to the project fixing this issue, but I couldn't run the tests. If you can help me solving this error, I could try to fix this myself and open a PR, I'm trying to learn a bit of Typescript 😄 When I first tried to run all the tests with
Then I tried to run only the
Maybe I have a wrong version installed of
|
Can you install and work with node v14. You can use |
Thanks @risenW, I will try it! |
Now I'm having a problem with ChromeHeadless in WSL2.
I saw that @sponsfreixes had a similar issue in #173, I will try to fix it myself 😅 |
@igonro I can't remember how I fixed the issue with headless chrome and WSL... I wonder if I ended ditching WSL and making it work on Windows, or even just running it on some other computer running a native Linux. Sorry for not being able to help on that! |
@sponsfreixes thanks for your response, and don't worry I was able to solve it and run the tests! 😄 |
@igonro great catch. this was as a result of code change from the previous version Here is how to fix the error base on column wise operation you made mention of. this line should be replace danfojs/src/danfojs-base/core/frame.ts Line 3165 in bdf0a24
to this const colDtype = this.dtypes Then to enable arithmetic operation for count, which is ideal for non-numerical columns, change this
to this if (typeof operation === "string") {
if (colDtype === "string" && operation !=="count") throw new Error(`Can't perform math operation on column ${colName}`)
}
else {
if (colDtype === "string" && operation[colName] !=="count") throw new Error(`Can't perform math operation on column ${colName}`)
} |
Describe the bug
When creating a DataFrame, depending on the order of the columns the
groupby()
function works properly or returns an error.To Reproduce
This column order works perfectly:
But when I change the column order to the following it doesn't work:
Expected behavior
I would expect that changing the order of the columns wouldn't make any change on the result.
Desktop (please complete the following information):
Additional context
I'm using the browser version, not the node.js one.
The text was updated successfully, but these errors were encountered: