I am trying to use Coda as a way to help students visualize data science using numpy / pandas.
I’m wondering if there’s a way to zero-index a table instead of 1-indexing so that it matches the indexing in python.
I am trying to use Coda as a way to help students visualize data science using numpy / pandas.
I’m wondering if there’s a way to zero-index a table instead of 1-indexing so that it matches the indexing in python.
Hi @Nikil_Ragav,
array indexing is a long (and infinite) debate whether if its better zero-based or one-based.
This is just one of the many dissertation in regards: Array Indexing: 0-based or 1-based? | by Kim Fung | Analytics Vidhya | Medium.
My background comes from computer science too, so I also have to mentally switch it every time.
However, considering the purpose and audience of Coda, I believe that Kim’s article perfectly points out the reason:
In addition, it [one-based] provides a much easier access to beginners as it is very intuitive for those who count from one!
The world is made of many good perspectives: let’s embrace most of them
You can have a column with a formula:
thisTable.Find(thisRow) - 1
to get your zero-based index (Find returns 1-based index, hence minus one).
FYI the reason why in programming indices are zero-based is because historically it’s not the index actually, but offset from the pointer pointing towards the first element of an array. I.e., an array of 128 bytes would be stored in the system as a pointer to its start, then each element would be retrieved as <pointer> + <offset>
where offset for the first element would obviously be zero. It is NOT because programmers count from zero.
Don’t mind me; it’s just that these “programmer jokes” about counting from zero and missing semicolons grind my gears the most.
Yep, familiar with pointers and offsets.
Yea, I have no problem with 1-indexing, but I’m trying to record a video to make it easier for students to visualize numpy using coda operations. Hence I asked.
I guess if I need to make an index column that’s what I’ll have to do but that’s a bit of a bummer!