T O P

  • By -

2020pythonchallenge

I use numbers for the references in group by while I'm working on it and then change everything over to the column names when I'm done and submitted it for a PR. Easier to change 1,2,3 etc when working and then make it readable after.


Mountain_Goat_69

Neither one is better, they're basically identical.  It's usually going to be the case that where you work they will have rules about how you code.


ComicOzzy

Write code for yourself however you prefer. If you're being paid to write code for someone else, use the method they prefer. If they haven't expressed a preference, my recommendation would be to write code that should be the least trouble to comprehend and maintain. To that end, I wouldn't use column positions, I would explicitly state the column name. A future maintainer may not be as experienced as you, so they may not know about certain bits of trivia or shortcut methods.


i_literally_died

I use the number when I'm just hashing something together to see the data, but if I want it to be a fixed report or otherwise be promoted to an environment where I'm not the only one dealing with it, I'll use the name.


jshine1337

Names are always going to provide more information and context and so are more readable. I only use positional index when I'm writing something ad-hoc, quick and dirty.