5 ms·
[Atwood's Law] This was inevitable I guess, but does anyone know if there's a decent Pandas equivalent for Javascript? I'd love to be able to handle reasonably
by fredley 8y ago
[Atwood's Law]
This was inevitable I guess, but does anyone know if there's a decent Pandas equivalent for Javascript? I'd love to be able to handle reasonably large datasets in Javascript as easily as I can in Python.
- 52-6F-62 8y agoNot sure this exactly helps you with your question, but check out Observable Notebooks (https://beta.observablehq.com/ https://beta.observablehq.com/). It's by Mike Bostock who wrote D3 (which people use to handle large data sets frequently). A quick search brought me here(https://stackoverflow.com/questions/30610675/python-pandas-equivalent-in-javascript https://stackoverflow.com/questions/30610675/python-pandas-e...) and here (https://stratodem.github.io/pandas.js-docs/#introduction)— https://stratodem.github.io/pandas.js-docs/#introduction)— not sure pandas-js is maintained any longer, though. edit: In that SO question, there's a pointer to Apache Arrow which appears to be maintained more regularly, with types—and library support for multiple languages. Never used it, myself, though. https://github.com/apache/arrow https://github.com/apache/arrow
- pablobaz 8y agohttps://www.ahl.com/short-review-of-dataframes-in-javascript https://www.ahl.com/short-review-of-dataframes-in-javascript A review of some options here.
- goatlover 8y agoOne thing that Python has that JS lacks is operator overloading, which allows for adding broadcasting. It's really nice to be able to do builtin math operations on Pandas columns or NumPy arrays. That's why languages like R, Julia and APL have broadcasting built in to the language. The mathematical notation is more natural and less cumbersome.
- rajangdavis 8y agoTwo things that JS has over Python is lexical scoping and map/reduce/filter and lambda support. JS can be verbose, but I find that functional style JS is, in my opinion, a bit more readable than Python list comprehensions.
- whalesalad 8y ago> Two things that JS has over Python is lexical scoping and map/reduce/filter and lambda support. ??? Python does all of that. There are native map/reduce/filter methods in the standard library. >>> x = [1, 2, None, 3] >>> list(filter(None, x)) [1, 2, 3] and then map >>> list(map(float, [1, 2, 3])) [1.0, 2.0, 3.0] Lambda's are everywhere in Python: >>> double = lambda x: x * 2 >>> list(map(double, range(3))) [0, 2, 4] https://docs.python.org/3/library/functions.html https://docs.python.org/3/library/functions.html
- rajangdavis 8y agoI know that they exist, but if you look at your examples, you have to manually cast maps into a list which is a bit strange coming from Ruby/JS/Scala. Once you have something sufficiently complex (such as using map, filter, and reduce all at the same time), there becomes so much line noise that it starts working against you. With JS/Ruby/Scala, you chain functional methods as opposed to Python where you can keep wrapping functions. Something like let arr = [0,1,2,'test']; arr .filter(x => typeof(x) == 'number') .map(x => x*2) .reduce((x, y) => x * y) becomes a little more cryptic with Python: from functools import reduce arr = [0,1,2,'test'] # with lambdas reduce(lambda x,y: x + y, map(lambda x: x * 2, filter(lambda x: type(x) == int, arr))) # list comprehension equivalent sum([x * 2 for x in arr if type(x) == int]) While Python is very beginner friendly, it has a really strange (in my opinion) approach to functional concepts. However, it is has other features that make it really nice to work with (like decorators, data classes, sets, robust ML libraries, really nice built ins).
- naveen99 8y agoChaining function calls makes things harder to debug, so I don’t do it.
- rajangdavis 8y agoI don't think it's any harder than broadcasting... I try to avoid chaining unless I know the structure of the data I am working with.