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

not be able to query data after reading from csv #22

Closed
samiragol opened this issue Sep 8, 2020 · 8 comments
Closed

not be able to query data after reading from csv #22

samiragol opened this issue Sep 8, 2020 · 8 comments

Comments

@samiragol
Copy link

I am reading data from a csv file. I want to query data with a very simple statement:

dfd.read_csv(dataPath)
.then(df => {
  let query_df = df.query({ column: "A", is: "==", to: "foo"});
  query_df.print();
})

it gives me this error: ReferenceError: bar is not defined and "bar" is one of the values in column "A"

@JhennerTigreros
Copy link
Contributor

Can you provide some rows of example from csv?

@samiragol
Copy link
Author

samiragol commented Sep 10, 2020

I used the same example in your github.

let data = { "Abs": [20, 30, 47] ,
            "Count": [34, 4, 5] ,
            "country code": ["NG", "FR", "GH"] }

@JhennerTigreros
Copy link
Contributor

Yes, the problem is in eval function that is used in frame.js

if (eval(`${elem}${operator}${value}`)) {
  new_data.push(data_value);
  new_index.push(index[i]);
}

becase eval function resolve the string to NG==NG and the engine try to get the variable NG that doesn't exits, I fix this changing the snippet code to

if (eval(`elem${operator}value`)) {
  new_data.push(data_value);
  new_index.push(index[i]);
}

and get the correct output

image

change it locally while fixing on main branch, the file is in /danfojs-node/dist/core/frame.js

@samiragol
Copy link
Author

thanks, is it going to be in the next release?

@JhennerTigreros
Copy link
Contributor

I open a pull request with the fix :)

@risenW
Copy link
Member

risenW commented Sep 10, 2020

@JhennerTigreros
Thanks for the fix. Will take a look and merge.

@risenW
Copy link
Member

risenW commented Sep 10, 2020

Merged! Thanks folks

@risenW risenW closed this as completed Sep 10, 2020
@fredthedead
Copy link

I'm using the version suggested in the repository README.md file
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.1.2/dist/index.min.js"></script>
and still getting this error... is this version the latest or is there a new one?

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

No branches or pull requests

4 participants