["python","pandas"]
How do I convert a Pandas series or index to a NumPy array?

How can I get the index or column of a DataFrame as a NumPy array or Python list?
To get a NumPy array, you should use the values attribute: In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}, index=['a', 'b', 'c']); df A B a 1 4 b 2 5 c 3 6 In [2]: df.index.values Out[2]: array(['a', 'b', 'c'], dtype=object) This accesses how the data is already stored, so there isn't any need for a conversion. Note: This attribute is also available for many other pandas objects. In [3]: df['A'].values Out[3]: Out[16]: array([1, 2, 3]) To get the index as a list, call tolist: In [4]: df.index.tolist() Out[4]: ['a', 'b', 'c'] And similarly, for columns.