Tan*_*y.L 1 python pandas raspberry-pi3
我知道有类似的问题,但没有人能够为我提供答案。我正在树莓派(模型 3)上运行 python 脚本。我正在使用 python 3,并且通过 pip install pandas 安装了 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
Run Code Online (Sandbox Code Playgroud)
这工作正常:
>>> test = pd.Dataframe()
Run Code Online (Sandbox Code Playgroud)
但这给了我以下错误消息:
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'`
Run Code Online (Sandbox Code Playgroud)
我检查了我的文件夹的名称。我没有名为 pandas 或 pd 的文件。我的树莓派是全新的。该脚本是文件夹中的唯一文件。
密码给了我: /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'
Run Code Online (Sandbox Code Playgroud)
我相信这段代码应该正确构建一个空的熊猫数据框。
用
data = pd.DataFrame()
Run Code Online (Sandbox Code Playgroud)
带有大写字母“F”。pd.Dataframe() (没有大写的“F”)不存在,所以它会抛出显示的错误。
| 归档时间: |
|
| 查看次数: |
7514 次 |
| 最近记录: |