python - Pandas read_csv 中的错误
问题描述
这是我的代码:
import matplotlib.pyplot as plt
import pandas as pd
import pylab as pl
import numpy as np
df = pd.read_csv("FuelConsumption.csv")
df.head()
并发生错误:
Traceback (most recent call last):
File "F:/python/machine learning/regression.py", line 8, in <module>
df = pd.read_csv("FuelConsumption.csv",engine = 'python')
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py", line 686, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py", line 452, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py", line 946, in __init__
self._make_engine(self.engine)
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py", line 1189, in _make_engine
self._engine = klass(self.f, **self.options)
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py", line 2382, in __init__
f, handles = get_handle(
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\pandas\io\common.py", line 496, in get_handle
f = open(path_or_buf, mode, errors="replace", newline="")
FileNotFoundError: [Errno 2] No such file or directory: 'FuelConsumption.csv'
我确定我已经下载了 csv 但它仍然无法正常工作有人可以帮助我吗?
解决方案
您应该知道您的工作区和 CSV 文件位于同一目录中。
推荐阅读
- ios - AWS Cognito 身份验证 + AWS 移动客户端 + API 网关 + S3 存储桶
- c# - 我需要使用 DLL C# 中的时间运行进度条
- javascript - Webpack 库间依赖,如 requireJS.config.shim
- python - NameError:未定义名称“类”
- c# - 返回 HTTP 403.7 HTTPResponseMessage
- postgresql - 将行值与文本字段与 CASE 中的无类型字符串文字行进行比较
- ios - 从没有 xcworkspace 的 .APP 包构建 IPA
- directshow - 如何捕获网络摄像头并附加到文件?
- testng - 如何验证 testNG 中的大整数?
- javascript - ReactJS - 使用三元运算符进行条件渲染 - InvalidValueError