danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

Adding Timeseries from .dt or toDateTime() to Series or DataFrame throws "Error: File format not supported!"

Open Emporea opened this issue 4 years ago • 1 comments

I tested it with danfojs-node and danfojs-node-nightly, because danfo.Dt includes the nightly.

What I have so far is this. Not a dt or danfo.toDateTime() operation yet.

const danfo = require("danfojs-node-nightly");

let index = ["0", "1", "2", "3"];
let value = [
  "2018-11-30T20:59:00",
  "2018-10-30T20:59:00",
  "2018-09-30T20:59:00",
  "2018-08-30T20:59:00",
];

let sf = new danfo.Series(value, { index });

console.log(sf.dt);

This is working and gives this. Danfo succesfully recognizes this string as a date.

TimeSeries {
  '$dateObjectArray': [
    2018-11-30T20:59:00.000Z,
    2018-10-30T20:59:00.000Z,
    2018-09-30T20:59:00.000Z,
    2018-08-30T20:59:00.000Z
  ]
}

But if I have a DataFrame where one column are dates then it is not possible to insert it into the DataFrame. Any single one of these functions results in the same error. Obviously only for demonstration all 4 in a row.

df["dates"] = df["dates"].dt
df["dates"] = danfo.toDateTime(dt["dates"])
let test_df = new danfo.DataFrame(sf.dt);
let test_sf = new danfo.Series(sf.dt);

Error: File format not supported!

Emporea avatar Jan 20 '22 01:01 Emporea

I tested it with danfojs-node and danfojs-node-nightly, because danfo.Dt includes the nightly.

What I have so far is this. Not a dt or danfo.toDateTime() operation yet.

const danfo = require("danfojs-node-nightly");

let index = ["0", "1", "2", "3"];
let value = [
  "2018-11-30T20:59:00",
  "2018-10-30T20:59:00",
  "2018-09-30T20:59:00",
  "2018-08-30T20:59:00",
];

let sf = new danfo.Series(value, { index });

console.log(sf.dt);

This is working and gives this. Danfo succesfully recognizes this string as a date.

TimeSeries {
  '$dateObjectArray': [
    2018-11-30T20:59:00.000Z,
    2018-10-30T20:59:00.000Z,
    2018-09-30T20:59:00.000Z,
    2018-08-30T20:59:00.000Z
  ]
}

But if I have a DataFrame where one column are dates then it is not possible to insert it into the DataFrame. Any single one of these functions results in the same error. Obviously only for demonstration all 4 in a row.

df["dates"] = df["dates"].dt
df["dates"] = danfo.toDateTime(dt["dates"])
let test_df = new danfo.DataFrame(sf.dt);
let test_sf = new danfo.Series(sf.dt);

Error: File format not supported!

This is related to this feature request #321 At the moment DateTime is not a standard data type in Danfojs. We will work on this pretty soon.

risenW avatar Jan 20 '22 08:01 risenW

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

risenW avatar Oct 12 '22 16:10 risenW