You really should try to pack an unbroken thought as a single line of code as much as possible. That’s the idea behind chaining multiple functions together on one line instead of spreading it out over several lines. Eyes go horizontally more naturally than up and down, it fits our vision’s natural aspect ratio. And stop making deep nestings. Making a single function call per line assigning output to a variable each t…
I agree with you on piping but writing each method on its own line makes the code very approachable (also easier to work with). Consider this code (from a course I'm teaching this week): (df .pipe(lambda df_: print(df_.columns) or df_) .groupby('activity_id', observed=True) [non_agg_cols] .apply(lambda g: g.assign(distance=calculate_distance_np(g)), include_groups=True) .pipe(fix_index) .pipe(lambda df_: print('DONE!…
“The quick brown fox jumped over the lazy ass dog”
Vs
The quick brown fox
jumped over
the lazy ass dog
The second example helps a reader understand the subjects and action but it is wholly unnecessary for people who know how to read.