Live data from Hacker News

Pandas 3.0

pandas.pydata.org

41–50 of 125 posts

Re: Pandas 3.0

#41
post #35

The design of Pandas is inferior in every way to Polars: API, memory use, speed, expressiveness. Pandas has been strictly worse since late 2023 and will never close the gap. Polars is multithreaded by default, written in a low-level language, has a powerful query engine, supports lazy, out-of memory execution, and isn’t constrained by any compatibility concerns with a warty, eager-only API and pre-Arrow data types th…

I would agree if not for the fact that polars is not compatible with Python multiprocessing when using the default fork method, the following script hangs forever (the pandas equivalent runs): import polars as pl from concurrent.futures import ProcessPoolExecutor pl.DataFrame({"a": [1,2,3], "b": [4,5,6]}).write_parquet("test.parquet") def read_parquet(): x = pl.read_parquet("test.parquet") print(x.shape) with Process…

I can't believe parallel processing is still this big of a dumpster fire in python 20 years after multi-core became the rule rather than the exception.

Do they really still not have a good mechanism to toss a flag on a for loop to capture embarrassing parallelism easily?

Re: Pandas 3.0

#42
post #19

Earlier quoted context omitted.

Went from pandas to polars to duckdb. As mentioned elsewhere SQL is the most readable for me and LLM does most of the coding on my end (quant). So I need it at the most readable and rudimentary/step-wise level. OT, but I can’t imagine data science being a job category for too long. It’s got to be one of the first to go in AI age especially since the market is so saturated with mediocre talents.

This is interesting. I wanted to dig into it a little since I am not sure I am following the logic of that statement. Do you mean that AI would take over the field, because by default most people there are already not producing anything that a simple 'talk to data' LLM won't deliver?

Not GP, but as a data engineer who has worked with data scientists for 20 years, I think the assessment is unfortunately true.

I used to work on teams where DS would put a ton of time into building quality models, gating production with defensible metrics. Now, my DS counterparts are writing prompts and calling it a day. I'm not at all convinced that the results are better, but I guess if you don't spend time (=money) on the work, it's hard to argue with the ROI?

Re: Pandas 3.0

#43

I've migrated off of pandas to polars for my workflows to reap the benefit of, in my experience a 10-20x speedup on average. I can't imagine anything bringing me back short of a performance miracle. LLMs have made syntax almost a non-barrier.

" 10-20x speedup on average. " Is this everyone's experience?

That was probably about what I got when I migrated some heavy number crunching code from Pandas to Polars a few years ago. Maybe even better than that.

Re: Pandas 3.0

#45
I have deep respect for Pandas, it, and Jupyter-lab were my intro to programming. And it worked much better for me, I did some "intro to Python" courses, but it was all about strs and ints. And yes, you can add strs together! Wow magic... Not for me. For me it all clicked when I first looped through a pile of Excel files (pd.read_excel()), extracted info I needed and wrote a new Excel file... Mind blown.

From there, of course, you slowly start to learn about types etc, and slowly you start to appreciate libraries and IDEs. But I knew tables, and statistics and graphs, and Pandas (with the visual style of Notebooks) lead me to programming via that familiar world. At first with some frustration about Pandas and needing to write to Excel, do stuff, and read again, but quickly moving into the opposite flow, where Excel itself became the limiting factor and being annoyed when having to use it.

I offered some "Programming for Biologists" courses, to teach people like me to do programming in this way, because it would be much less "dry" (pd.read.excel().barplot() and now you're programming). So far, wherever I offered the courses they said they prefer to teach programming "from the base up". Ah well! I've been told I'm not a programmer, I don't care. I solve problems (and that is the only way I am motivated enough to learn, I can't sit down solving LeetCode problems for hours, building exactly nothing).

(To be clear, I now do the Git, the Vim, the CI/CD, the LLM, the Bash, The Linux, the Nix, the Containers... Just like a real programmer, my journey was just different, and suited me well, I believe others can repeat my journey and find joy in programming, via a different route.)

Re: Pandas 3.0

#46
post #40
post #38

Earlier quoted context omitted.

Polars took a lot of ideas from Pandas and made them better - calling it "inferior in every way" is all sorts of disrespectful :P Unfortunately, there are a lot of third party libraries that work with Pandas that do not work with Polars, so the switch, even for new projects, should be done with that in mind.

Luckily, polars has .to_pandas() so you can still pass pandas dataframes to the libraries that really are still stuck on that interface. I maintain one of those libraries and everything is polars internally.

to_pandas has a dependency on pandas - it is not the biggest of deals, but worth keeping in mind.

Re: Pandas 3.0

#47
post #35

Earlier quoted context omitted.

I would agree if not for the fact that polars is not compatible with Python multiprocessing when using the default fork method, the following script hangs forever (the pandas equivalent runs): import polars as pl from concurrent.futures import ProcessPoolExecutor pl.DataFrame({"a": [1,2,3], "b": [4,5,6]}).write_parquet("test.parquet") def read_parquet(): x = pl.read_parquet("test.parquet") print(x.shape) with Process…

I can't believe parallel processing is still this big of a dumpster fire in python 20 years after multi-core became the rule rather than the exception. Do they really still not have a good mechanism to toss a flag on a for loop to capture embarrassing parallelism easily?

Well I think ProcessPoolExecutor/ThreadPoolExecutor from concurrent.futures were supposed to be that

Re: Pandas 3.0

#48
post #35

The design of Pandas is inferior in every way to Polars: API, memory use, speed, expressiveness. Pandas has been strictly worse since late 2023 and will never close the gap. Polars is multithreaded by default, written in a low-level language, has a powerful query engine, supports lazy, out-of memory execution, and isn’t constrained by any compatibility concerns with a warty, eager-only API and pre-Arrow data types th…

I would agree if not for the fact that polars is not compatible with Python multiprocessing when using the default fork method, the following script hangs forever (the pandas equivalent runs): import polars as pl from concurrent.futures import ProcessPoolExecutor pl.DataFrame({"a": [1,2,3], "b": [4,5,6]}).write_parquet("test.parquet") def read_parquet(): x = pl.read_parquet("test.parquet") print(x.shape) with Process…

You are not wrong, but for this example you can do something like this to run in threads:

  import polars as pl
  
  pl.DataFrame({"a": [1, 2, 3]}).write_parquet("test.parquet")
  
  
  def print_shape(df: pl.DataFrame) -> pl.DataFrame:
      print(df.shape)
      return df
  
  
  lazy_frames = [
      pl.scan_parquet("test.parquet")
      .map_batches(print_shape)
      for _ in range(100)
  ]
  pl.collect_all(lazy_frames, comm_subplan_elim=False)
(comm_subplan_elim is important)

Re: Pandas 3.0

#49
post #35

Earlier quoted context omitted.

I would agree if not for the fact that polars is not compatible with Python multiprocessing when using the default fork method, the following script hangs forever (the pandas equivalent runs): import polars as pl from concurrent.futures import ProcessPoolExecutor pl.DataFrame({"a": [1,2,3], "b": [4,5,6]}).write_parquet("test.parquet") def read_parquet(): x = pl.read_parquet("test.parquet") print(x.shape) with Process…

I can't believe parallel processing is still this big of a dumpster fire in python 20 years after multi-core became the rule rather than the exception. Do they really still not have a good mechanism to toss a flag on a for loop to capture embarrassing parallelism easily?

This is one of the reasons I use polars.

Re: Pandas 3.0

#50
post #35

The design of Pandas is inferior in every way to Polars: API, memory use, speed, expressiveness. Pandas has been strictly worse since late 2023 and will never close the gap. Polars is multithreaded by default, written in a low-level language, has a powerful query engine, supports lazy, out-of memory execution, and isn’t constrained by any compatibility concerns with a warty, eager-only API and pre-Arrow data types th…

I would agree if not for the fact that polars is not compatible with Python multiprocessing when using the default fork method, the following script hangs forever (the pandas equivalent runs): import polars as pl from concurrent.futures import ProcessPoolExecutor pl.DataFrame({"a": [1,2,3], "b": [4,5,6]}).write_parquet("test.parquet") def read_parquet(): x = pl.read_parquet("test.parquet") print(x.shape) with Process…

Python 3.14 "spawns" by default.

However, this is not a Polars issue. Using "fork" can leave ANY MUTEX in the system process invalid (a multi-threaded query engine has plenty of mutexes). It is highly unsafe and has the assumption that none of you libraries in your process hold a lock at that time. That's an assumption that's not PyTorch dataloaders to make.

Post reply on HN