Error when using .eq with Array
Code
const filters = [1, 2, 3, 4, 5];
console.log(filters);
return df.query(df.colA.eq(filters));
Output
(5) [1, 2, 3, 4, 5]
Uncaught Error: LengthError: length of other must be equal to length of Series
same problem with df = df.loc({ rows: df['id'].eq(['a', 'b']) }) I wonder if this library is missing an option to filter with an array
same problem with df = df.loc({ rows: df['id'].eq(['a', 'b']) }) I wonder if this library is missing an option to filter with an array
I've found a work around to this problem
`const dfd = require("danfojs-node") const data = [ ['asefwc', 'Abdullah', 'Cumilla'], ['wefcss', 'Khairul', 'Jashore'], ['erfegf', 'Jaman', 'Magura'] ]
const columns = ['id', 'name', 'address']
let df = new dfd.DataFrame(data, { columns })
let ids = df['id'].values // get all the column values
let allRowsToInclude = []
idsToInclude.forEach((idToInclude) => { const rowsToInclude = ids.flatMap((id, idx) => id === idToInclude ? idx : []) allRowsToInclude = allRowsToInclude.push(... rowsToInclude) }
// creates a new df with filtered rows let dfFinal = df.loc({rows: allRowsToInclude}) `
Code
const filters = [1, 2, 3, 4, 5]; console.log(filters); return df.query(df.colA.eq(filters));Output
(5) [1, 2, 3, 4, 5] Uncaught Error: LengthError: length of other must be equal to length of Series
From the error message, it looks like the length of df.colA. and filter is not the same. They must be the same for `.eq. to work.