pyspark.sql.DataFrame.toPandas#
- DataFrame.toPandas()[source]#
Returns the contents of this
DataFrameas Pandaspandas.DataFrame.This is only available if Pandas is installed and available.
New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
Notes
This method should only be used if the resulting Pandas
pandas.DataFrameis expected to be small, as all the data is loaded into the driver’s memory.Usage with
spark.sql.execution.arrow.pyspark.enabled=Trueis experimental.Examples
>>> df.toPandas() age name 0 2 Alice 1 5 Bob