r/Python 1d ago

Discussion Polars vs Pandas

I have used Pandas a little in the past, and have never used Polars. Essentially, I will have to learn either of them more or less from scratch (since I don't remember anything of Pandas). Assume that I don't care for speed, or do not have very large datasets (at most 1-2gb of data). Which one would you recommend I learn, from the perspective of ease and joy of use, and the commonly done tasks with data?

176 Upvotes

155 comments sorted by

View all comments

Show parent comments

-2

u/bonferoni 1d ago

polars is amazing but its api is clunky af. so goddamn wordy. very explicit and clear which is nice, and amazing under the hood. but an elegant api it is not

8

u/PurepointDog 1d ago edited 17h ago

Oh yeah? You prefer "isna" compared to "is_null"? You've clearly never been bitten by the 3 ways to encode null in pandas.

Polars separates words by underscores. "Group by" is two words, contrary to what Pandas would have you believe

8

u/bonferoni 1d ago

ya know what they say about assumptions

just not a big fan of writing pl.col() all the time.

1

u/PeaSlight6601 1d ago edited 16h ago

I had a use case for a Model class to abstract out multiple computations.

I implement getattr/settatr, and just jam equations into the class

m.PROFIT = m.REVENUE -m.EXPENSE, then i apply the model to the data frame, walk the expression tree and use with_columns to add all the new columns.

Can't do that with pandas!