Gmousse / dataframe-js

No Maintenance Intended
https://gmousse.gitbooks.io/dataframe-js/
MIT License
460 stars 38 forks source link

[BUG] DataFrame is not a constructor #134

Open irohitb opened 2 years ago

irohitb commented 2 years ago

Bug.

I am doing this

`import DataFrame from 'dataframe-js'`

 const df = new DataFrame({c1: 1, c2: 6, c3: 9, c4: 10, c5: 12}, ['c1', 'c2', 'c3', 'c4', 'c5', 'c6'])

but this keeps throwing error that DataFrame is not a constructor

Gmousse commented 2 years ago

Hi, Indeed, the default export seems not working well.

It seems working when not importing the default.

Workaround in esm:

import { DataFrame } from "dataframe-js";

const df = new DataFrame([[1, 2, 3]], ["a", "b", "c"]);

or in cjs:

const DataFrame = require("dataframe-js").default;

const df = new DataFrame([[1, 2, 3]], ["a", "b", "c"]);
irohitb commented 2 years ago

@Gmousse Thanks, I was able to make it work using the workaround.

DanKaplanSES commented 1 year ago

@Gmousse I came here to report a similar issue, but I was going to suggest updating the documentation, as this took me 20+ minutes to troubleshoot.

Alternatively/even better, you could fix the default export to work the way the documentation says it will. I don't have the time at the moment to research how to do that, but it might be a breaking change for others that already use the library. I'm not sure if that's an option.