OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Terminology for ordinal index versus dataframe index

  • Thread starter Thread starter Pro Q
  • Start date Start date
P

Pro Q

Guest
I've set up a dataframe:

Code:
df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Aritra'],
                   'Age': [25, 30, 35],
                   'Location': ['Seattle', 'New York', 'Kona']},
                  index=([10, 20, 30]))

I ask the user to put in which row of the data they want to see. They input a 0, indicating the first row.

However, df.loc[0] does not refer to the first row. Instead, it doesn't exist, because the index only has the values 10, 20, and 30.

Is there terminology to distinguish these two types of indexes? The best I could come up with is ordinal indexes (for "What number row is this?") and dataframe indexes (for "What is the index of this row in the dataframe?").

To clarify, this would mean that one could do df.index(ordinal_index) = df_index.

Is there a standard terminology for this?
<p>I've <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.index.html" rel="nofollow noreferrer">set up a dataframe</a>:</p>
<pre><code>df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Aritra'],
'Age': [25, 30, 35],
'Location': ['Seattle', 'New York', 'Kona']},
index=([10, 20, 30]))
</code></pre>
<p>I ask the user to put in which row of the data they want to see. They input a <code>0</code>, indicating the first row.</p>
<p>However, <code>df.loc[0]</code> does not refer to the first row. Instead, it doesn't exist, because the <code>index</code> only has the values 10, 20, and 30.</p>
<p>Is there terminology to distinguish these two types of indexes? The best I could come up with is <em>ordinal indexes</em> (for "What number row is this?") and <em>dataframe indexes</em> (for "What is the index of this row in the dataframe?").</p>
<p>To clarify, this would mean that one could do <code>df.index(ordinal_index) = df_index</code>.</p>
<p>Is there a standard terminology for this?</p>
 

Latest posts

Online statistics

Members online
0
Guests online
3
Total visitors
3
Top