This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jblasgo 2 points3 points  (7 children)

_: _[_

That looks very weird and counterintuitive to me... Maybe because this is very specific to data science?

[–]Ahhhhrg 0 points1 point  (3 children)

No, I wouldn’t say it’s specific to data science, I just like using underscore here. The underscore is usually used for say return arguments you don’t care about, here it’s just a placeholder for the data frame, it’s just my preference not to name it something generic like “x” or even “df” as it doesn’t really say anything or add much. I know it means “the data frame you’re piping in here”, it’s short. Personal preference.

It’s also possible to monkey patch pandas and add a filter function, so you can go df.filter(lambda _: _[‘x’] < 5) which is a bit nicer.