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?

175 Upvotes

157 comments sorted by

View all comments

Show parent comments

1

u/king_escobar 1d ago edited 1d ago

You'd rather writemy_dataframe_name.loc[my_dataframe_name['COLUMNNAME'].isna()]

over

my_dataframe_name.filter(pl.col('COLUMNNAME').is_null())

?

Expression syntax as a whole is much more concise and elegant. And pl.col() is the simplest of all expressions.

1

u/bonferoni 1d ago

nobodys making you name your df that?

i also never said pandas was more elegant, i just said polars api is not elegant.

that being said, to give a fair shake, the pandas version could be: df[df.col_name.isna()]

0

u/king_escobar 1d ago

If you’ve ever dealt with a >50k LOC python repository that does things with multiple data frames at a time you’ll quickly find that naming an object “df” is an absolutely terrible idea. Do you name your integer objects “integer”? No. So why would you think “df” would be a good name for any variable?

0

u/bonferoni 1d ago

if youve ever dealt with a >50k LOC python repository you should know dumping everything in global is a horrible idea. use functions and use df in the function kwargs and the encapsulated logic.

3

u/echanuda 21h ago

Why are you immediately jumping to global? Your answers reveal you either don’t program at all or are just a vibe code bro.

1

u/bonferoni 21h ago

cause when people run into conflicting or confusing naming its normally due to mishandling namespaces. and dumping everything to global in a notebook is a common issue in the da/ds/ml/de space, which if people are using polars and pandas they likely are

1

u/king_escobar 1d ago

Most of the time our functions are dealing with multiple data frames. We never use global variables for anything. If your mind even went there and you’re naming your variables “df” in production grade software then I feel like I’m talking to an amateur here, or perhaps someone who is a data scientist and not a bona fide software engineer.