cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

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

1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz
Community Manager
Community Manager

Hi @Rakesh Reddy Gopidi​, Please remove ".dtypes" from the line:-

orders_df = spark.read.json("/public/retail_db_json/orders").dtypes

View solution in original post

2 REPLIES 2

Kaniz
Community Manager
Community Manager

Hi @Rakesh Reddy Gopidi​, Please remove ".dtypes" from the line:-

orders_df = spark.read.json("/public/retail_db_json/orders").dtypes

Kaniz
Community Manager
Community Manager

Hi @Rakesh Reddy Gopidi​ ​, We haven’t heard from you since the last response from me, and I was checking back to see if you have a resolution yet.

If you have any solution, please share it with the community as it can be helpful to others. Otherwise, we will respond with more details and try to help.

Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.