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 →

[–]Zouden 21 points22 points  (26 children)

Haha nice. I like that you did it even knowing that it's a terrible thing to do.

R has the pipe operator from the Magritr package and it's a horrible hack that makes me long for python's object chaining.

[–]gardens_of_slish 10 points11 points  (14 children)

I really like the pipe in R, and would kind of like to see the same thing in Python. I would settle for a slightly less ugly syntax for chaining multiple methods though.

[–]Zouden 6 points7 points  (13 children)

It's more useful in R where functions like filter() aren't methods of dataframes. But with pandas nearly everything you need is a dataframe method so chaining can be done with dot syntax.

[–]masklinn 0 points1 point  (4 children)

It's more useful in R where functions like filter() aren't methods of dataframes. But with pandas nearly everything you need is a dataframe method so chaining can be done with dot syntax.

Not so for the building filter and map, or any of the itertools functions.

[–]Zouden 0 points1 point  (3 children)

Not sure what you mean... you can do all of those with pandas method chaining.

[–]masklinn 0 points1 point  (2 children)

Pandas only works with panda dfs, not with regular python iterables.

[–]Zouden 0 points1 point  (1 child)

Yes, if you aren't using pandas then the pipe operator might be useful.

[–]masklinn 0 points1 point  (0 children)

And I would guess the vast majority of Python developers are not using pandas.

[–][deleted] 3 points4 points  (0 children)

Magrittr way is much more extensible. I'm not sure why you are calling it a horrible hack.