Indexing wishful thinking and interfacing...
So in Python lists, the first element has position 0. In numpy arrays, the first record has position 0 and the first field also has position 0 and arr[3, 5] would be the fourth record in the sixth field (record is before field and separate by comma). So much is clear. For those of us who grew up with Microsoft Excel, the references in arrays are column first then row, and 1 is the first row. In Excel the cell reference ""0 doesn't exist. A1 exists. My question is, why can't they align the logic so we don't have to remember? In other words, what's the rationale of keeping 0 instead of 1 as the first position in Python and Numpy? Zed Shaw rambles about it in his Lean Python the Hard Way but I don't buy his explanation.
10/9/2020 4:30:40 AMNassim Abed
3 AnswersNew Answer
Indexes are used as an offset which when used in array tells you that so and so element is so and so blocks away from the starting address. In C language the array name holds the starting address so in order to fetch that element through a pointer variable, you had to move 0 blocks and to access the next element you have to move 1 block. Here is an example. https://code.sololearn.com/ciUBLmoH6Sr0 Now since most of the languages were built on top of the C language, they have inherited the same.
Thanks all. I guess perspectives will vary based on where each one started. I started learning Python out of wanting to apply in data analysis: one book and one SL course into it, I am still using Excel and Minitab to do my analysis and visualization and statistics and I am still to see the power that Python adds to these interface-bases tools. I am now doing the DS SL course and studying a book on Python for Data Analysis.