For a given df, I know you can access a specific column (say, column
) from a df
by doing something like:
df.column
I wanted to see if you could get the indices in a similar fashion. The first thing I tried was:
df.index
This returns an index which might look something like:
RangeIndex(start=0, stop=5, step=1)
I see this has a method from_range
, but it doesn't seem capable of just extracting the index, as a string, for me. I want the index because I want to migrate it into another table to serve as a key-map. Is there a way to just extract the index directly? In theory I could reset the index and just use the range(len(df))
as a surrogate, but I'm interested in this just in case I wanted to keep a chaotic index for whatever reason.