Live data from Hacker News

Pandas vs. Julia – cheat sheet and comparison

datascientyst.com

71–80 of 138 posts

Re: Pandas vs. Julia – cheat sheet and comparison

#71
post #12

Earlier quoted context omitted.

You have never read documentation on something you’re not currently writing code with _right_ _now_? Or looked at documentation for something you worked on in the day as you’re on your way home from work? I opened it on mobile because I was interested in seeing how they differ, even though I’m not using either right now.

Well, I typically don't read a lot on mobile. Screen is too small and you can't block ads, which makes the screen even smaller.

You totally can block ads.

Re: Pandas vs. Julia – cheat sheet and comparison

#73
post #68

The thing that keeps me coming back to Julia is the ability to pipe (or whatever you want to call it). It makes DataFrame operations a lot cleaner since I don't need to modify in place or create new DFs at intermediate steps in a process. Here's a video showing this sort of workflow in R: https://youtu.be/W3e8qMBypSE

In pandas you can chain commands by wrapping the whole command in (). Personally IMO looks far 'cleaner' than all of the ugly %>% everywhere.

The flip side is that in pandas, chaining is less uniform because it is based on methods.

In R you can pipe a data frame into any function from any package or one you just wrote, so you use %>% for any piping that happens. In pandas, you have special pandas methods that don't need the pipe, but to pipe with any other function, you have to write .pipe.

The comparison is not really between %>% and ., it's between "you just use %>% for everything" and "you use . for a bloated, somewhat arbitrary collection of special pandas methods, and .pipe for everything else".

Re: Pandas vs. Julia – cheat sheet and comparison

#74
post #70

Earlier quoted context omitted.

Indeed DataFrames.jl isn't and won't be the fastest way to do many things. It makes a lot of trade offs in performance for flexibility. The columns of the dataframe can be any indexable array, so while most examples use 64-bit floating point numbers, strings, and categorical arrays, the nice thing about DataFrames.jl is that using arbitrary precision floats, pointers to binaries, etc. are all fine inside of a DataFra…

I really hope people don't come from R to Julia. People who use R are not good programmers, and will degrade the core of the language and it's principles. It would be a shame to see the equivalent of tacking on 6 different object oriented systems to a base language and fragmenting the community completely.

I'm not sure I'd have the same take. Yes, R as a language is kind of wonky and people who use R tend to not be good programmers. However, the APIs of some packages are designed well enough that even with all of those barriers it can still be easy to use for many scientists. I wouldn't copy the language, 6 different object systems and non-standard evaluation is weird. But there is a lot to learn from the APIs of the tidyverse and how it has somehow been able to cover for all of those shortcomings. It would be great to see those aspects with the data science libraries of the Julia language.

Re: Pandas vs. Julia – cheat sheet and comparison

#75
post #70

Earlier quoted context omitted.

Indeed DataFrames.jl isn't and won't be the fastest way to do many things. It makes a lot of trade offs in performance for flexibility. The columns of the dataframe can be any indexable array, so while most examples use 64-bit floating point numbers, strings, and categorical arrays, the nice thing about DataFrames.jl is that using arbitrary precision floats, pointers to binaries, etc. are all fine inside of a DataFra…

I really hope people don't come from R to Julia. People who use R are not good programmers, and will degrade the core of the language and it's principles. It would be a shame to see the equivalent of tacking on 6 different object oriented systems to a base language and fragmenting the community completely.

R users in the form of statisticians should definitely come around to Julia. More high quality packages never hurt. But I agree with fragmentation and 'object systems', yet I don't think this is a huge danger for Julia.

Re: Pandas vs. Julia – cheat sheet and comparison

#76

Yeah this is basically why I keep trying and bouncing off Julia. I understand the real performance reasons why you'd choose to use Julia but the syntax is the perfect distance from python to make it extremely difficult to me. It's just close enough to get constantly confused. So if I really wanted to do much work in it I'd have swear off python - and I can't do that because for trivial stuff python is more convenient…

I have done both complex and trivial stuff in both languages and Julia isn't more inconvenient for trivial things.

Any examples? I've found Julia far easier for simple things than python. Most modern problems are mathematical and nature and I think it's pretty objective that julia looks closer to the mathematics. ----Some tests of very simple tasks in both languages.

At its most basic the obviouses becomes different:

Let's try to get a very simple object: a 3,3 matrix of random booleans in both languages: Julia:

A = rand(Bool,3,3)

Python: No standard support for Matrices. I could really do it a disservsice and comapre the "core language", but that''s obivously stupid so we'll bring in some external libraries to make it easier. Of many ways to skin the cat here's one.. Python

import numpy.numpy as np gen = np.random.default.default_rng() B = gen.choice([True,False],(3,3))

BTW julia has this choice function built into the command as well, so rand(["Which", "Word", "Will", "I", "get?"]) produces exactly what you'd expect.

----

Acutally I can't think of any cases at all off the top of my head. Sorry, I mean my np.somenamespace.another.namespace.sparce head :) I mean just going down the list of things that make code easier in Julia..

* Python requires a third party library for any kind of linear algebra. and matrix multiplication:*

  A =[1 4;6 7"; B = [2 ;3]; A*B doesn't work, i.e. you literally even multiply a matrix! This is madness.you'll need yet again a third partly library
Python doesnt have broadcasting. let's apply sin(x) to a matrix a Pythonic(+ required third party libraries)

  import numpy as np
 import math #sigh
      x = np.array([1, 2, 3, 4, 5])
      f = lambda x: sin(x)

Now in Julia (notice the . after sin) x=1:5 sin.(x) or more explicity we could write broadcast(sin, x)

Even basic string interpolation in Julia is a much nicer "trivial task" than in python alone

No special brackets, just clean "$myvar"

# Reading files is easier

Julia

    readlines("my_test.txt")
Python

open("my_test.txt").readlines()

What a stupid option in 2? if I call readlines on a filename, 99% of people, 99% of the time, want to read the lines on the file at that path. Why require two function calls?

Re: Pandas vs. Julia – cheat sheet and comparison

#78

Anxiously waiting for pandas to get its mojo. If there is any Python library that needs it, this is it.

I wish Python catches up to Julia in performance. No sense rewriting a trillion lines of code for what is a really pleasant syntax & ecosystem already.

But this is a language flamewar thing, probably not a constructive comment, sorry.

Re: Pandas vs. Julia – cheat sheet and comparison

#79

Earlier quoted context omitted.

For what it's worth this is literally how the Julia community deals with feedback.

Well it's not my website. Although the feedback does seem very "this toaster doesn't work when I try to cook soup in it! 1/5" Not everything needs to cater to mobile.

It seems more like you're saying "It's ok that your toaster doesn't cook pop-tarts, you shouldn't be having those anyway--the sugar's bad for you." Your way of doing things might not be everybody's.

Nothing has to cater to anything but I'm still allowed to be annoyed that I can't read it on mobile.

Re: Pandas vs. Julia – cheat sheet and comparison

#80
post #19

Yeah this is basically why I keep trying and bouncing off Julia. I understand the real performance reasons why you'd choose to use Julia but the syntax is the perfect distance from python to make it extremely difficult to me. It's just close enough to get constantly confused. So if I really wanted to do much work in it I'd have swear off python - and I can't do that because for trivial stuff python is more convenient…

I have not done anything even remotely significant in Julia, but the little I played with didn't seem to indicate to me that it would be bad for trivial stuff...what trivial stuff is hard in Julia but easy in Python?

I responded in detail him about, but honestly I can't think of many that answer your qiestion. It's amost always the opposite. A I like to present this as stereotypical example of the types of differences you find the two, IMO. Generating a 3x3 matrix of random booleans.

>Julia

  A = rand(Bool,3,3)
Python: No standard support for Matrices. I could really do it a disservsice and comapre the "core language", but that''s obivously stupid so we'll bring in some external libraries to make it easier. Of many ways to skin the cat here's one..

>Python

   import numpy.numpy as np
      gen = np.random.default.default_rng()
      B = gen.choice([True,False],(3,3))

I find myself just taking `rand(["Msg1",.....,"MsnN"])` to get a random string often. And small things like this are why you see people Julia is so nice to write and become so defendant of it.
Post reply on HN