我知道有类似的问题,但没有一个能给我答案。我在一个raspberry pi(model 3)上运行一个python脚本。我使用的是python3和pandas是通过pip安装pandas安装的。我的代码可以运行import pandas as pd
,但是test = pd.Dataframe
给了我一个错误:AttributeError: module 'pandas' has no attribute 'Dataframe'
如下面我的代码所示,我已经检查了我的代码是否有一个正确的pandas模块。在
我还直接在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
这很好:
^{pr2}$但这给了我以下错误消息:
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'`
我查了一下文件夹的名字。我没有叫熊猫或警察的档案。我的rapsberry pi是全新的。脚本是文件夹中唯一的文件。在
pwd给了我:/home/pi/sensehat_projects/Raspb_fitbit/rasp_code
以及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'
我认为这段代码应该正确地构建一个空的pandas数据帧。在
使用
大写字母“F”。 pd.数据帧()(不带大写字母“F”)不存在,因此它将抛出显示的错误。在
相关问题 更多 >
编程相关推荐