Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module 'pandas' has no attribute 'DataFrame'

Tags:

python

import pandas as pd 
import dateutil

# Load data from csv file
data = pd.DataFrame.from_csv('phone_data.csv')
# Convert date from string to date times
data['date'] = data['date'].apply(dateutil.parser.parse, dayfirst=True)

The above code causes the error: "module 'pandas' has no attribute 'DataFrame'"

I'm new to Python and am attempting to use this tutorial: Summarising, Aggregating, and Grouping data in Python Pandas

Any suggestions on what could be causing the error? I've noticed others have had the same question, but the proposed solutions don't seem to apply in my case.

like image 632
user2525015 Avatar asked Mar 13 '18 18:03

user2525015


People also ask

How do you fix pandas has no attribute DataFrame?

Conclusion # The Python "AttributeError module 'pandas' has no attribute 'DataFrame'" occurs when we have a local file named pandas.py or misspell DataFrame . To solve the error, make sure to rename any local files named pandas.py .

How do you solve a DataFrame object has no attribute?

Fix error while creating the dataframe If we use dataframe it will throw an error because there is no dataframe attribute in pandas. The method is DataFrame(). We need to pass any dictionary as an argument. Since the dictionary has a key, value pairs we can pass it as an argument.

What is pandas module in Python?

Pandas is an open source library in Python. It provides ready to use high-performance data structures and data analysis tools. Pandas module runs on top of NumPy and it is popularly used for data science and data analytics.

How do you convert PySpark DF to pandas DF?

Convert PySpark Dataframe to Pandas DataFramePySpark DataFrame provides a method toPandas() to convert it to Python Pandas DataFrame. toPandas() results in the collection of all records in the PySpark DataFrame to the driver program and should be done only on a small subset of the data.


1 Answers

Alright OP, figured this one out. Not exactly sure why this is the case, but it's because of what you named your file. Somehow naming your script dateutil.py and importing dateutil/pandas is causing a problem.

I got the same error locally until I renamed it. Try renaming your file to something like myfile.py and your problem should be solved.

like image 66
Peter Dolan Avatar answered Sep 19 '22 06:09

Peter Dolan