【发布时间】:2021-01-06 14:04:00
【问题描述】:
import numpy as np
import pandas as pd
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
import matplotlib.pyplot as plt
%matplotlib inline
filepath = "G:\learning python\page view time series\trum.csv"
df = pd.read_csv(filepath, index_col = "date", parse_dates=True)
上面的代码给出了以下错误:
OSError: [Errno 22] Invalid argument: 'G:\\learning python\\page view time series\trum.csv'
但是,如果我将 csv 文件的名称更改为“laem.csv”并更新路径,那么代码将完美运行。
import numpy as np
import pandas as pd
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
import matplotlib.pyplot as plt
%matplotlib inline
filepath = "G:\learning python\page view time series\laem.csv"
df = pd.read_csv(filepath, index_col = "date", parse_dates=True)
为什么会这样?
【问题讨论】:
-
让我们直接阅读。
filepath =r"G:\learning python\page view time series\laem.csv" -
@wwnda。不错的收获!
标签: python pandas csv path filepath