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

Support ObservableHQ #197

Closed kalebpace closed 3 years ago

kalebpace commented 3 years ago

Is your feature request related to a problem? Please describe. Cannot import danfo into an ObservableHQ notebook. I have seen forum posts where people seem to have danfo working in a notebook, but there are no official examples and the methods of importing I have tried do not work.

image

Describe the solution you'd like Would like to run dfd = require('danfojs@0.2.5') to provide dataframes to the notebook

Describe alternatives you've considered

UPDATE It figures I would find a code snippet shortly after creating this issue. Below imports danfo, maybe add to official guide?

image

steveoni commented 3 years ago

@kalebpace sorry for the late reply. Here are some materials that could help: https://observablehq.com/@visnup/hello-danfo-js https://heartbeat.fritz.ai/end-to-end-machine-learning-in-javascript-using-danfo-js-and-tensorflow-js-part-1-223223c83935

selenecodes commented 2 years ago

For people wondering how to get it to work on version 1.0.3 change the path to the lib/bundle.js file like so:

dfd = require("danfojs@1.0.3/lib/bundle.js").catch(() => {
  window.dfd.Series.prototype.print = window.dfd.DataFrame.prototype.print = function () {
    return print(this);
  };
  return window.dfd;
})
risenW commented 2 years ago

For people wondering how to get it to work on version 1.0.3 change the path to the lib/bundle.js file like so:

dfd = require("danfojs@1.0.3/lib/bundle.js").catch(() => {
  window.dfd.Series.prototype.print = window.dfd.DataFrame.prototype.print = function () {
    return print(this);
  };
  return window.dfd;
})

Thanks for sharing @selenecodes In case anyone is interested, I have put together a starter Observable notebook: https://observablehq.com/@risingodegua/using-danfojs-on-observablehq