javascriptdata / danfojs

Danfo.js is an open source, JavaScript library providing high performance, intuitive, and easy to use data structures for manipulating and processing structured data.
https://danfo.jsdata.org/
MIT License
4.81k stars 209 forks source link

version: 0.3.3 danfo.query converts column headers to numbers #492

Closed archanaanz closed 2 years ago

archanaanz commented 2 years ago

Describe the bug filter_from = "Business Unit" filter_value = "Engineering (Code 1234)"

let df_subset = df_basedata.query({ column: filter_from, is: "==", to: filter_value })

df_subset has column headers as numbers rather than headers from df_basedata.

if version 1.0.0 is used then it errors as:

indexing.ts:33 Uncaught Error: rows parameter must be an Array. For example: rows: [1,2] or rows: ["0:10"] at _iloc (indexing.ts:33:1) at DataFrame.query (frame.ts:2290:27) at ProcessExcel (xxx.js:124:33) at Upload.reader.onload (xxx.js:48:21) _iloc @ indexing.ts:33 DataFrame.query @ frame.ts:2290 ProcessExcel @ xxx.js:124 Upload.reader.onload @ xxxjs:48

  1. See error

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

risenW commented 2 years ago

let df_subset = df_basedata.query({ column: filter_from, is: "==", to: filter_value })

Hi, for newer version of danfojs, you can need to pass a boolean mask to the query function. So use this instead:

let df_subset = df.query(df_basedata["filter_from"].eq(filter_value))