[Python] 纯文本查看 复制代码
import pandas as pd
import os
import datetime
path = r'C:\Users\plm\Desktop\text1'
files = os.listdir(path)
for file in files:
df =pd.read_excel(file)
Traceback (most recent call last):
File "<ipython-input-44-eaa09722c597>", line 12, in <module>
df =pd.read_excel(file)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\util\_decorators.py", line 296, in wrapper
return func(*args, **kwargs)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 304, in read_excel
io = ExcelFile(io, engine=engine)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 867, in __init__
self._reader = self._engines[engine](self._io)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\io\excel\_xlrd.py", line 22, in __init__
super().__init__(filepath_or_buffer)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 353, in __init__
self.book = self.load_workbook(filepath_or_buffer)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\io\excel\_xlrd.py", line 37, in load_workbook
return open_workbook(filepath_or_buffer)
File "D:\ProgramData\Anaconda3\lib\site-packages\xlrd\__init__.py", line 111, in open_workbook
with open(filename, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'a.xlsx'
index = (df.iloc[(df['datetime2'] > 2020-11-2)].index)
Traceback (most recent call last):
File "<ipython-input-45-f3d918f4f26d>", line 1, in <module>
index = (df.iloc[(df['datetime2'] > 2020-11-2)].index)
NameError: name 'df' is not defined
ndf = df.drop(index)
Traceback (most recent call last):
File "<ipython-input-46-411ce523224e>", line 1, in <module>
ndf = df.drop(index)
NameError: name 'df' is not defined
ndf.to_excel(file)
Traceback (most recent call last):
File "<ipython-input-47-5c94f9f205b4>", line 1, in <module>
ndf.to_excel(file)
NameError: name 'ndf' is not defined
ndf = df.drop(index)
Traceback (most recent call last):
File "<ipython-input-48-411ce523224e>", line 1, in <module>
ndf = df.drop(index)
NameError: name 'df' is not defined
|