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.76k stars 209 forks source link

Danfojs not working with React Typescript #125

Closed PascalStehling closed 3 years ago

PascalStehling commented 3 years ago

Hi,

When I try using React with typsecript and danfojs I allways get the error "Module not found: Can't resolve 'danfojs/danfojs/types/core/frame'" when trying to import danfojs. When using React with Javascript everything is fine, just with Typescript the Error occures.

I allso tried the Generated files like Descripted in #73, but an similar error occured.

I just changed my used App.tsx, the rest is the standard React Typescript App that you can Generate with npx create-react-app testapp --template typescript. Does anybody know where the Problem is or what I can do to fix this?

App.tsx (from the react example, just the import was changed):

import React from 'react';
import "./App.css";
import { DataFrame } from 'danfojs/danfojs/types/core/frame';

function App() {

  const df = new DataFrame(
    { pig: [20, 18, 489, 675, 1776], horse: [4, 25, 281, 600, 1900] },
    { index: [1990, 1997, 2003, 2009, 2014] }
  );
  df.head().print()

  return (
    <div className="App">
      <header className="App-header">
        <a
          className="App-link"
          href="https://danfo.jsdata.org/getting-started"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn Danfojs 
        </a>
      </header>
    </div>
  );
}

export default App;
nicolashedoire commented 3 years ago

@PascalStehling you can create a JSX file in your project to use Danfo

PascalStehling commented 3 years ago

@nicolashedoire Thanks, I got around the Problem by using const dfd:any = require("danfojs/danfojs/src/index").