5 ms·
This is what 0-based indexing looks like in data analysis: >In order to read a csv in that doesn't have a header and for only certain columns you need to pass
by ChrisRackauckas 8y ago
This is what 0-based indexing looks like in data analysis:
>In order to read a csv in that doesn't have a header and for only certain columns you need to pass params header=None and usecols=[3,6] for the 4th and 7th columns:
https://stackoverflow.com/questions/29287224/pandas-read-in-table-without-headers https://stackoverflow.com/questions/29287224/pandas-read-in-...
Just reading that hurts me.
- dangom 8y agoThis is very much a non-argument. Call the columns the 4th and 7th is as arbitrary as calling them the 3rd and the 6th. Again, 0-based indexing exists to fit a purpose: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW... In my opinion, reading `a = b[1:n-1]` hurts much more than reading `a = b[:n]`.
- coldtea 8y ago>Call the columns the 4th and 7th is as arbitrary as calling them the 3rd and the 6th. No, that's their ordinal position, and how 8 billion non-programmers would refer them as in any everyday setting. That's also how programmers would refer to them if it wasn't for a historical accident. What's more, that's also how programmers refer to them when they talk between then and not to the machine ("check the 3rd column" not "check the column at the index of 2").
- e12e 8y agoa = b[1..n]?
- DNF2 8y agoThe equivalent of `a = b[:n]` is `a = b[1:n]`. And I don't think you can get around admitting that there is a fundamental ambiguity in the spoken statement "Take a look at the fourth column!" in a zero-based index system. You always need a follow-up question to clarify whether you mean "everyday informal speech fourth" or "zero-index fourth."
- beojan 8y agoBut you can say "Take a look at column 4" instead, which is unambiguous.
- Certhas 8y agoIt's not arbitrary. It's English. In the list [apple, orange, tree] which element is orange? It's the second element. I have taught Python quite a bit, and I have gotten good at explaining 0 based indexing and slicing based on it. When I switched to Julia there was nothing to explain. And my code has about as many +/- 1s as before...
- jacobolus 8y agoJust because it is our common convention in lay conversation doesn’t mean it isn’t “arbitrary”. These spoken language conventions developed before there was an established name for “zero” or even a concept that “nothing” could be a number per se. For similar reasons, we have no zero cards in our decks, no zero faces on a dice, no zero hour on our clocks, no zero year in our calendar, no zeroth floors in our buildings, East Asian babies are born with age one year, etc. It’s only by another set of historical accidents that we have a proper 0 in our method of writing down whole numbers. Thankfully that one was of obvious enough benefit that it became widely adopted.
- FabHK 8y ago> no zeroth floors in our buildings In (North?) America. In Europe, there's a ground floor (zero), then first floor (1), etc. Basement is -1 (etc.). A European friend of mine arrived at college in the USA, and was assigned a room on the first floor of the dorm. She then asked the housing office whether there was a lift, because she had quite some heavy luggage, earning some rather amused looks :-)
- thousandautumns 8y agoCalling the 3rd and 6th columns "3rd" and "6th" is hardly arbitrary.