Comments (8)
Thanks for pointing that out @techieshark!
I think we might be better of with using +
for parsing numbers, since indeed it behaves better than parseFloat
. I don't think we should go as far as trying to handle formatted numbers, we could mention that in the docs.
What do you think @nickslevine?
from zebras.
Thanks for pointing out, @techieshark!
@amytych Seems as if the +
operator doesn't fix the problem with the commas in number-strings, unless I'm missing something?
Couldn't hurt to put a warning in the docs to start and then file an enhancement issue for smarter parsing? What do you both think?
from zebras.
Seems as if the + operator doesn't fix the problem with the commas in number
Hehe, yes, I'm aware, I just meant it's better in a way that it returns NaN
when it can't parse a string as a number, which seems more appropriate than a totally incorrect number like parseFloat
does, e.g:
As for the smarter parsing I'm worried it might be a mine field and out of scope of this library. Dealing with localized formats might be too much of a hustle, as also pointed out in the SO thread linked in the issue it's not trivial to do in a reliable manner. (tldr: commas might mean very different things in formatted strings)
from zebras.
One more note, seems that using +
would make it behave similar to pandas.to_numeric()
with errors="coerce"
setting?
https://repl.it/repls/VainWiltedSeptagon
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_numeric.html
from zebras.
@amytych cool cool, that all makes a lot of sense!
from zebras.
Just switched parseFloat() with + and added a note re:commas in the README. @techieshark thanks for flagging!
@amytych - I wasn't quite sure how to update the docs website - mind reminding me how the build process works? Thanks!
from zebras.
Great you actioned this @nickslevine, thanks!
I'd still consider a PR route even for such a seemingly small case, some things worth thinking about a bit more here:
- improving tests to cover as many edge cases as possible
- should we consider handling empty strings?
+"" === 0
âšī¸ - when releasing we should perhaps bump the major version since it might not be backwards compatible?
- worth explaining the behavior a bit more within the
parseNums
docs as well (or at least repeat what you've put in the main README)?
I'll look into publishing new docs đ
from zebras.
That all makes sense - sound good!
from zebras.
Related Issues (20)
- Add different types of joins and ability to join on multiple columns to merge function
- Why check `node_modules` into the repo? HOT 1
- Question about `head` and `tail` HOT 1
- Make zebras browser friendly HOT 5
- Add https to zebrasjs.com HOT 1
- Add tests HOT 1
- Typescript type definitions HOT 14
- Optimise z.readCSV() HOT 3
- Implement map for groupby objects
- Does not handle multiline column headers
- Does not import data with a comma in them HOT 2
- gbCount, gbMean etc. not curried HOT 1
- (latest npm package) Does not import data with a comma in them HOT 2
- Implement merge
- [fix] - fix wrong function declaration mistake on toCSV.js.html & index.d.ts
- Write project roadmap document
- Build out groupBy functionality
- Implement resampling
- Add instructions for setting up a Jupyter notebook with JS kernel + zebras + vega-lite
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zebras.