pyspark.pandas.Index.to_list¶
-
Index.
to_list
() → List¶ Return a list of the values.
These are each a scalar type, which is a Python scalar (for str, int, float) or a pandas scalar (for Timestamp/Timedelta/Interval/Period)
Note
This method should only be used if the resulting list is expected to be small, as all the data is loaded into the driver’s memory.
Examples
Index
>>> idx = ps.Index([1, 2, 3, 4, 5]) >>> idx.to_list() [1, 2, 3, 4, 5]
MultiIndex
>>> tuples = [(1, 'red'), (1, 'blue'), (2, 'red'), (2, 'green')] >>> midx = ps.MultiIndex.from_tuples(tuples) >>> midx.to_list() [(1, 'red'), (1, 'blue'), (2, 'red'), (2, 'green')]