AttributeError:模块“pandas”没有rapsberry Pi的属性“Dataframe”

2024-04-19 01:53:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道有类似的问题,但没有一个能给我答案。我在一个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数据帧。在


Tags: pipno代码inimportdataframepandasline