Home > Enterprise >  DataBricks- How to save DataFrame to table in Python
DataBricks- How to save DataFrame to table in Python

Time:04-26

i have a dataframe, called pydf.

How do i save this as a table within databricks? I tried pydf.write and I get the message "DataFrame object has no attribute write"

So how do i save this then?

CodePudding user response:

    from pyspark.sql import SparkSession
    spark = SparkSession.builder.getOrCreate()

    spark_df = spark.createDataFrame(pydf)
    spark_df.write.mode("overwrite").saveAsTable("example")
  • Related