←back to thread

498 points azhenley | 9 comments | | HN request time: 0.209s | source | bottom
1. acdbddh ◴[] No.45772097[source]
In python its common to see code like this:

  df = pd.concat(df,other_df)
  df = df.select(...)
  ...
My eyes hurts, when I see it. It makes me avoid python. I bet the reason for this mutable code is a missing simple pipes syntax. I love pipes. In R can do:

  df |> 
    rbind(other_df) |> 
    select(...)
It feels much better.
replies(5): >>45772142 #>>45772222 #>>45772564 #>>45772704 #>>45776281 #
2. mr_luc ◴[] No.45772142[source]
Elixir too (Explorer library; default backend is Pola.rs based)

- https://github.com/elixir-explorer/explorer - https://hexdocs.pm/explorer/Explorer.html

3. fermisea ◴[] No.45772222[source]
pandas has a .pipe operator which works exactly like this
4. cubefox ◴[] No.45772564[source]
Wouldn't that be simply:

  df = pd.concat(df,other_df).select(...)
5. leviathan ◴[] No.45772704[source]
My eyes would hurt more if I had to look all day at the vertical misalignment of that |> operator
replies(1): >>45772843 #
6. kec ◴[] No.45772843[source]
You could always switch to a better font like Fira Code which has a ligature for this.
replies(1): >>45774463 #
7. adregan ◴[] No.45774463{3}[source]
The gp's comment wasn't made regarding the look of the operator in its ascii representation `|>` but about the vertical misalignment.

Typically you align a pipeline like so:

     df
     |> rbind(other_df)
     |> select(...)
But these topics are largely left to code formatters these days.
replies(1): >>45778757 #
8. zenlot ◴[] No.45776281[source]
Nah, it doesn't. Although you can do similar in Elixir.
9. kec ◴[] No.45778757{4}[source]
Weird, I have always aligned as the gp showed. I’m reasonably sure tidyverse documentation does the same (which is probably where we both picked it up from).