r/Python • • 1d ago

Discussion Polars for data-heavy datasets

A few months back I switched from pandas to polars because some of the datasets I needed to work with were hitting the million row mark and beyond. It has taken quite some time to get used to the more verbose polars dataframe methods but I have to say I am really pleased with the execution speed improvement.

I also moved away from applying filters and calculating, migrating to the group_by.agg() for performing row calculations - HUGE difference in speed.

For those of you who haven't heard of polars, it is multi-threaded whereas pandas is single-threaded, so for large datasets it is faster. I would never have made the switch were it not for large datasets, and I frequently convert to pandas dataframes when debugging.

Anyone else have similar experiences or have resisted the urge to migrate away from pandas?

88 Upvotes

42 comments sorted by

View all comments

-2

u/Actual__Wizard 1d ago edited 1d ago

A few months back I switched from pandas to polars because some of the datasets

Yes, I'm working with data that is deep into the trillions of rows.

After years of working with both pandas and polars, dealing with them breaking under the load of data that big, or being mega slow, I built my own database tech from the ground up to handle tables up to int(64) in length and the system supports up to int(64) columns in theory.

A lot of sacrifices had to be made to get the performance level up to "feels like it's instant."

I want to be clear, that I felt like Polars was fine up until you get into the multiple millions of rows, or at least in my application, the performance is "not good enough for my application with data sets beyond like 10m+ rows." I need like 1t rows/sec traverse speed (bsearch does that) w/ like 100k+ rows/sec of retrieval (structured data does that.) So, it's "double structured" and it was a massive pain in the butt to build it.

4

u/CaptainFoyle 21h ago

Ok

-1

u/Actual__Wizard 21h ago

That's a really weird comment. We live in an era where things like atomic scale simulations of cells are totally possible, but we don't have data tech to do stuff like that. It breaks instead of doing what we need it to do. It's really frustrating. It seems like people designed these systems based upon their goals and not based upon what exists in reality.

0

u/CaptainFoyle 12h ago

Just choose your units

0

u/Actual__Wizard 2h ago

Robot...

1

u/CaptainFoyle 2h ago

That's a really weird comment

1

u/justanothersnek 19h ago

There's also sqlframe you could use too. It is PySpark API on top of popular SQL backends.