How do I get a DataFrame Index / Series column as an array or list?

Do you know how to get the index column of an dataframe as an array? I have a list of accession numbers in the "Accession" column of a CSV file, which I imported into Pandas, and during the import, I set the index to the "Accession" column. Now, I need the "Accession" column to be a set of labels in a later step, but I don't know how to extract it standalone.

To get a NumPy array, you should use the values attribute:

    In [1]: df = pd.DataFrame(index=['a', 'b'])

    In [2]: df.index.values
    Out[2]: array(['a', 'b'], dtype=object)

This accesses how the data is already stored, so there's no need for a conversion.
Note: This attribute is also available for many other pandas' objects.

To get the index as a list, call tolist:

    In [3]: df.index.tolist()
    Out[3]: ['a', 'b']

From: stackoverflow.com/q/17241004