How do I convert a pandas Series or index to a Numpy array?
You can use df.index to access the index object and then get the values in a list using df.index.tolist(). Similarly, you can use df['col'].tolist() for Series.
Do you know how to get the index or column of a DataFrame as a NumPy array or python list?