GithubHelp home page GithubHelp logo

Comments (4)

jospueyo avatar jospueyo commented on June 2, 2024

Debugging a bit I found that the problem is with the null values. However, it is expected to have null values in a database. So, I don't know if this should be tagged as a bug.

from nodejs-polars.

universalmind303 avatar universalmind303 commented on June 2, 2024

The inference used to detect the schemas for readRecords is a bit behind the upstream polars. Updating that to use the latest code from polars should likely fix most inference related issues.

the nodejs readRecords should behave identically to the python from_dicts. So if you are able to create using python from_dicts, then it is definitely a bug in nodejs-polars. Otherwise, i'd suggest opening up an issue with polars.

from nodejs-polars.

jospueyo avatar jospueyo commented on June 2, 2024

I tried in both languages and in Python works properly:

Python:

import polars as pl

test = [
    {"a": 1, "b": "a", "c": "x"},
    {"a": 2, "b": None, "c": "y"},
]

test_df = pl.from_dicts(test)

print(test_df)

# shape: (2, 3)
#┌─────┬──────┬─────┐
#│ a   ┆ b    ┆ c   │
#│ --- ┆ ---  ┆ --- │
#│ i64 ┆ str  ┆ str │
#╞═════╪══════╪═════╡
#│ 1   ┆ a    ┆ x   │
#│ 2   ┆ null ┆ y   │
#└─────┴──────┴─────┘

Nodejs:

const pl = require("nodejs-polars")

let test = [
    {a: 1, b: "a", c:"x"},
    {a: 2, b: null, c: "y"}
]

let testDF = pl.readRecords(test)

console.log(testDF)

// thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src\dataframe.rs:1527:29
// note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

However, it works if the null values are dropped:

const pl = require("nodejs-polars")

let test = [
    {a: 1, b: "a", c:"x"},
    {a: 2, c: "y"}
]

let testDF = pl.readRecords(test)

console.log(testDF)

// shape: (2, 3)
// ┌─────┬──────┬─────┐
// │ a   ┆ b    ┆ c   │
// │ --- ┆ ---  ┆ --- │
// │ f64 ┆ str  ┆ str │
// ╞═════╪══════╪═════╡
// │ 1.0 ┆ a    ┆ x   │
// ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌┤
// │ 2.0 ┆ null ┆ y   │
// └─────┴──────┴─────┘

from nodejs-polars.

Bidek56 avatar Bidek56 commented on June 2, 2024

This issue is fixed in 0.8.0.
Please try it, if it works, please close the ticket. Thx

from nodejs-polars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.