danfojs
danfojs copied to clipboard
DataFrame.copy() does not make a deep copy of the data.
Describe the bug DataFrame.copy() does not make a deep copy of the data, only a shallow copy!
The reason is the spread operation in copy(), which is used instead of a proper deep copy.
To Reproduce
const orig = new DataFrame(...);
const copy = orig.copy();
console.log(copy.values === orig.values); // logs false!
console.log(copy.values[0] === orig.values[0]); // logs true!
Expected behavior In the example above, the second console log should log false.
I am having the same problem. I am currently getting around this with:
const copy = new dfd.DataFrame(dfd.toJSON(original));
although it would of course be preferable if the copy function behaved as documented :)
Almost One year later and this issue has not been fixed. Thanks @nholmes3 for te workaround!!