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

datetime error pass throw new Error("File format not supported!"); #483

Closed Zourvan closed 2 years ago

Zourvan commented 2 years ago

Describe the bug I have date read from mongodb like these: [ { timestamp: 1659052014, DateTime: 2022-07-28T23:46:54.732Z, open: 6751.64577992092, close: 5195.775137545757, high: 1524.0121578845155, low: 6562.21988608587, volume: 1947.899689556545 }, { timestamp: 1659052016, DateTime: 2022-07-28T23:46:56.732Z, open: 1356.56558520725, close: 5338.004939325953, high: 3838.3290561580384, low: 6306.352967310171, volume: 5595.6236089073855 }]

when I try to convert to Json use the toJSON with format : "row" the error throw: throw new Error("File format not supported!"); after remove Datetime from my data the error solved!!! but if format : "column" everything's are OK

Expected behavior throw new Error("File format not supported!");

Desktop (please complete the following information):

risenW commented 2 years ago

At the moment, Danfojs does not have first-class support for parsing DateTime on read.

You should represent the date column as a string, and any manipulation should be done on it after converting to a datetime using the Dt class (https://danfo.jsdata.org/api-reference/general-functions/danfo.dt) or directly on the Series by calling the .dt accessor, e.g https://danfo.jsdata.org/api-reference/series/series.dt.second