Void S
Void S

Reputation: 802

DataBricks- How to save DataFrame to table in Python

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?

Upvotes: 1

Views: 5066

Answers (1)

ZVY545
ZVY545

Reputation: 404

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

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

Upvotes: 3

Related Questions