Home > database >  AttributeError: 'DataFrame' object has no attribute 'write'...Trying to upload a
AttributeError: 'DataFrame' object has no attribute 'write'...Trying to upload a

Time:01-06

I have created a dataframe in databricks as a combination of multiple dataframes. I am now trying to upload that df to a table in my database and I have used this code many times before with no problem, but now it is not working. My code is

df.write.saveAsTable("dashboardco.AccountList")

getting the error: AttributeError: 'DataFrame' object has no attribute 'write'

Thanks for any help!

CodePudding user response:

Most probably your DataFrame is the Pandas DataFrame object, not Spark DataFrame object.

try:

spark.createDataFrame(df).write.saveAsTable("dashboardco.AccountList")
  • Related