AttributeError: 'list' object has no attribute 'columns' - PySpark

db-avengers2rul
Contributor II

Hi All,

i am getting the below error when i am ingesting the data from source file , source file is also attached , i have tried in both Community edition and Azure databricks as well getting the same error , can any one suggest me the solution ?

 # reading a df for orders
orders_df = spark.read.json("/public/retail_db_json/orders").dtypes
 
# displaying the columns 
orders_df.columns
 
# Error
AttributeError: 'list' object has no attribute 'columns'
 

Regards,

Rakesh