pyspark.pandas.Index.to_numpy#
- Index.to_numpy(dtype=None, copy=False)[source]#
- 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. - Parameters
- dtypestr or numpy.dtype, optional
- The dtype to pass to - numpy.asarray()
- copybool, default False
- Whether to ensure that the returned value is not a view on another array. Note that - copy=Falsedoes not ensure that- to_numpy()is no-copy. Rather,- copy=Trueensures that a copy is made, even if not strictly necessary.
 
- Returns
- numpy.ndarray
 
 - 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)