I know there are similar questions, but none was able to provide me with an answer. I am running a python script on a raspberry pi (model 3). I am using python 3 and pandas is installed trough pip install pandas. My code is able to run the line import pandas as pd, but test = pd.Dataframe gives me an error: AttributeError: module 'pandas' has no attribute 'Dataframe'
As shown in my code below, I have checked that my code has a proper pandas module.
I also checked directly in python:
`Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
This works fine:
>>> test = pd.Dataframe()
But this gives me the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.7/site-packages/pandas/__init__.py", line 214, in __getattr__
raise AttributeError("module 'pandas' has no attribute'{}'".format(name))
AttributeError: module 'pandas' has no attribute 'Dataframe'`
I checked my folder's name. I have no file called pandas or pd. My rapsberry pi is brand new. The script is the only file in the folder.
A pwd gives me: /home/pi/sensehat_projects/Raspb_fitbit/rasp_code
and ls -a:
. .. .DS_Store weather_script.py
try:
from pip._internal.operations import freeze
except ImportError: # pip < 10.0
from pip.operations import freeze
x = freeze.freeze()
for p in x:
print(p)
# prints a list of modules (pandas==0.25.0)
from sense_hat import SenseHat
import time
import sys
import os
import pandas as pd
data = pd.Dataframe()
Traceback (most recent call last):
File "weather_script.py", line 18, in <module>
data = pd.Dataframe()
File "/home/pi/.local/lib/python3.7/site-packages/pandas/__init__.py", line 214, in __getattr__
raise AttributeError("module 'pandas' has no attribute '{}'".format(name))
AttributeError: module 'pandas' has no attribute 'Dataframe'
I believe this code should properly build an empty pandas dataframe.
Use
data = pd.DataFrame()
With a capital ‘F’. pd.Dataframe() (without the capital ‘F’) doesn’t exist, so it will throw the error shown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With