pyspark.sql.DataFrameWriter.save

DataFrameWriter.save(path=None, format=None, mode=None, partitionBy=None, **options)[source]

Saves the contents of the DataFrame to a data source.

The data source is specified by the format and a set of options. If format is not specified, the default data source configured by spark.sql.sources.default will be used.

Parameters
  • path – the path in a Hadoop supported file system

  • format – the format used to save

  • mode

    specifies the behavior of the save operation when data already exists.

    • append: Append contents of this DataFrame to existing data.

    • overwrite: Overwrite existing data.

    • ignore: Silently ignore this operation if data already exists.

    • error or errorifexists (default case): Throw an exception if data already exists.

  • partitionBy – names of partitioning columns

  • options – all other string options

>>> df.write.mode("append").save(os.path.join(tempfile.mkdtemp(), 'data'))

New in version 1.4.