danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

Selecting `Date` column blows up

Open hrseymour opened this issue 3 years ago • 1 comments

Create a data frame with a Date column. Example value: new Date("2022-04-01"). Try to select the data column using [either documented method](new Date("2022-04-01")). Code blow ups with this call stack:

[./node_modules/danfojs-node/dist/danfojs-base/core/generic.js:91]()
                throw new Error("File format not supported!");
                      ^

Error: File format not supported!
    at Series.NDframe ([./node_modules/danfojs-node/dist/danfojs-base/core/generic.js:91:23]())
    at new Series ([./node_modules/danfojs-node/dist/danfojs-base/core/series.js:136:28]())
    at DataFrame.$getColumnData ([./node_modules/danfojs-node/dist/danfojs-base/core/frame.js:198:24]())
    at DataFrame.get ([./node_modules/danfojs-node/dist/danfojs-base/core/frame.js:149:37]())
    at [file://./cmdLineUtils/commander.mjs:139:21]()
    at ModuleJob.run (node:internal[/modules/esm/module_job:195:25]())
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal[/modules/esm/loader:337:24]())
    at async loadESM (node:internal[/process/esm_loader:88:5]())
    at async handleMainPromise (node:internal[/modules/run_main:61:12]())

Node.js v17.4.0

hrseymour avatar Mar 02 '22 23:03 hrseymour

@hrseymour We do mot have first class support for Date type at the moment. Unless it’s a string Datatype, you cannot work with Data objects directly.

So to fix this, ensure your Date column is a collection of Date Strings, then call the .dt method on it to use the Dates.

risenW avatar Mar 07 '22 07:03 risenW

Fixed in https://github.com/javascriptdata/danfojs/pull/511

risenW avatar Oct 12 '22 16:10 risenW