r/Python • u/silicon_turfsurfer • 2d 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?
View all comments
Show parent comment
1
u/SV-97 1d ago
It somewhat depends: mostly yes, but there are some functions that lazy frames can't support directly (in the worst case that means you have to insert another collect at that point). But polars should tell you about any such problematic parts when you make the change.
I mean it always depends on how large yours rows are etc. --- but I think 3 Million is still "basically nothing" relative to what polars is built to be able to handle :) The number of rows in my last project was more on the order of billions and that was probably still way less than what other people have to deal with (IIRC it was ultimately "just" around 100GB of data with filesystem level compression)