简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM