Index.
to_numpy
A NumPy ndarray representing the values in this Index or MultiIndex.
Note
This method should only be used if the resulting NumPy ndarray is expected to be small, as all the data is loaded into the driver’s memory.
The dtype to pass to numpy.asarray()
numpy.asarray()
Whether to ensure that the returned value is not a view on another array. Note that copy=False does not ensure that to_numpy() is no-copy. Rather, copy=True ensures that a copy is made, even if not strictly necessary.
copy=False
to_numpy()
copy=True
Examples
>>> ps.Series([1, 2, 3, 4]).index.to_numpy() array([0, 1, 2, 3]) >>> ps.DataFrame({'a': ['a', 'b', 'c']}, index=[[1, 2, 3], [4, 5, 6]]).index.to_numpy() array([(1, 4), (2, 5), (3, 6)], dtype=object)