简体   繁体   English

文件未找到 Matplotlib 线图有 2 行

[英]File Not Found Matplotlib Line Plot with 2 lines

Thank you in advance for your help!预先感谢您的帮助!

Data for minot_air minot_air 的数据

Data for minot_soil minot_soil 的数据

I am trying to graph two datasets to one plot and I want it to look somewhat like the first image.我试图将两个数据集绘制成一个图,我希望它看起来有点像第一个图像。 The problem is that I keep getting these errors when I run my code (provided below):问题是我在运行代码时不断收到这些错误(如下提供):

FileNotFoundError: [Errno 2] File C:\\Users\\Xavier\\Desktop\\minotDailyAirTemp.csv does not exist: 'C:\\Users\\Xavier\\Desktop\\minotDailyAirTemp.csv' FileNotFoundError: [Errno 2] 文件 C:\\Users\\Xavier\\Desktop\\minotDailyAirTemp.csv 不存在:'C:\\Users\\Xavier\\Desktop\\minotDailyAirTemp.csv'

Why might I be getting these errors?为什么我会收到这些错误? I have checked and that is indeed the location of each of the files.我已经检查过,这确实是每个文件的位置。 Images two and three show them on my desktop as well as show the file hierarchy:图片二和三在我的桌面上显示它们并显示文件层次结构:

在此处输入图片说明

在此处输入图片说明 在此处输入图片说明

import pandas as pd
import numpy as np


# data import
minot_air_temp = pd.read_csv(r"C:\Users\Xavier\Desktop\minotDailyAirTemp.csv")
minot_soil_temp = pd.read_csv(r"C:\Users\Xavier\Desktop\Minot_20CM_Daily.csv")

air_temp = pd.read_csv(minot_air_temp, header = 0, index_col = 0,
                         parse_dates=True, infer_datetime_format=True)
soil_temp = pd.read_csv(minot_soil_temp, header = 0, index_col = 0,
                       parse_dates=True, infer_datetime_format=True)

# plot both overlayed
ax = air_temp.plot(figsize=(20,10))
soil_temp.plot(ax=ax)

Error 1:错误 1:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-51-f1b5480c283a> in <module>
      4 
      5 # data import
----> 6 minot_air_temp = 
pd.read_csv(r"C:\Users\Xavier\Desktop\minotDailyAirTemp.csv")
      7 minot_soil_temp = 
pd.read_csv(r"C:\Users\Xavier\Desktop\Minot_20CM_Daily.csv")
      8 

~\anaconda3\lib\site-packages\pandas\io\parsers.py in 
parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, 
usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, 
true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, 
na_values, keep_default_na, na_filter, verbose, skip_blank_lines, 
parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, 
cache_dates, iterator, chunksize, compression, thousands, decimal, 
lineterminator, quotechar, quoting, doublequote, escapechar, comment, 
encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, 
low_memory, memory_map, float_precision)
    674         )
    675 
--> 676         return _read(filepath_or_buffer, kwds)
    677 
    678     parser_f.__name__ = name

~\anaconda3\lib\site-packages\pandas\io\parsers.py in 
_read(filepath_or_buffer, kwds)
    446 
    447     # Create the parser.
--> 448     parser = TextFileReader(fp_or_buf, **kwds)
    449 
    450     if chunksize or iterator:

~\anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, f, 
engine, **kwds)
    878             self.options["has_index_names"] = kwds["has_index_names"]
    879 
--> 880         self._make_engine(self.engine)
    881 
    882     def close(self):

~\anaconda3\lib\site-packages\pandas\io\parsers.py in _make_engine(self, 
engine)
   1112     def _make_engine(self, engine="c"):
   1113         if engine == "c":
-> 1114             self._engine = CParserWrapper(self.f, **self.options)
   1115         else:
   1116             if engine == "python":

~\anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, src, 
**kwds)
   1889         kwds["usecols"] = self.usecols
   1890 
-> 1891         self._reader = parsers.TextReader(src, **kwds)
   1892         self.unnamed_cols = self._reader.unnamed_cols
   1893 

pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()

pandas\_libs\parsers.pyx in 
pandas._libs.parsers.TextReader._setup_parser_source()

FileNotFoundError: [Errno 2] File 
C:\Users\Xavier\Desktop\minotDailyAirTemp.csv does not exist: 
'C:\\Users\\Xavier\\Desktop\\minotDailyAirTemp.csv'

In the images you included it appears that the files are directly in the Desktop directory and not in a Graphs folder.在您包含的图像中,文件似乎直接位于 Desktop 目录中,而不是位于 Graphs 文件夹中。

Should the file path be “C:\\Users\\Xavier\\Desktop”?文件路径应该是“C:\\Users\\Xavier\\Desktop”吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM