cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!