danfojs
danfojs copied to clipboard
`sf.apply` not working with dates
Using danfo-node, with node 16...
timestamp is a column created from new Date() instance
const sfHourly = df.column('timestamp').apply((date) => {
const dt = new Date(date);
dt.setMinutes(0);
return dt;
});
This code throws the following message TypeError: arr.slice is not a function
I can confirm this bug comes from is1DArray utility that it only checks if typeof arr as:
if (
typeof arr[0] == "number" ||
typeof arr[0] == "string" ||
typeof arr[0] == "boolean" ||
arr[0] === null
) {
return true;
} else {
return false;
}
since datetime is an object, so the implementatio wrongly treats array of datetime as 2d Array.