question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sample.toJSON() broke in 1.0.5

See original GitHub issue

Describe the bug sample.toJSON() broke in 1.0.5 looks like the frame returned by df.sample() is from base - src/danfojs-base/core/frame.ts and not from the node one.

To Reproduce Steps to reproduce the behavior:

// install 1.0.5
import {DataFrame} from 'danfojs-node'

const df = new DataFrame([{a: 1}, {b: 2}])
console.log(df.toJSON())
const sample = await df.sample(1)
console.log(sample.toJSON())

Expected behavior sample.toJSON() should return

[ { a: 1 } ]

Screenshots image

Desktop (please complete the following information):

  • OS: MacOS 11.5.2 M1 2020
  • Browser: Node v17.7.2
  • Version v17.7.2

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
odjheycommented, Apr 4, 2022

hi @risenW, super thanks! I wouldve sent a PR for a fix but my powers was not enough hehe. BTW! Thanks for working on danfojs, really helping our small team big time! 😃 We’ll find ways to contribute better in the future! Again, super thanks ".)👍🏼

1reaction
odjheycommented, Apr 3, 2022

hmm, after some digging, i think any method that returns the base version of DataFrame like (sample, head, add, etc) will not include the io functions defined in node-df/browser-df. Functions include toCSV, toJSON, toExcel

im directly using the exported toJSON for now (below example)

import {DataFrame, toJSON} from 'danfojs-node'

const df = new DataFrame([{a: 1}, {b: 2}])
console.log(df.toJSON())
const sample = await df.sample(1)

// console.log(sample.toJSON()) // <--- replace baseDf.toJSON() with the one from import {toJSON} from 'danfojs-node'
console.log(toJSON(sample))

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or ...
Read more >
generatePackageJson on nx 15 generates the the ... - GitHub
Current Behavior npm ci of a a copied apps dist directory breaks after update to nx 15 because the root package-lock.json dependency version ......
Read more >
ECMAScript 5 Strict Mode, JSON, and More - John Resig
The Date constructor now attempts to parse the date as if it was ISO-formatted, first, then moves on to the other inputs that...
Read more >
How to check if a string is a valid JSON string? - Stack Overflow
First example using eval says that "<div>foo</div>" is valid JSON. It may work differently in different browsers, but it appears that in FireFox,...
Read more >
pandas.DataFrame.to_json — pandas 1.5.2 documentation
PathLike[str]), or file-like object implementing a write() function. ... result = df.to_json(orient="split") >>> parsed = json.loads(result) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found