程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python:No such file or directory

編輯:Python
The phenomenon and background of the problem

Python The small white , One is due at the end of this term python Homework , But the following problems occur repeatedly when writing good code , Please answer me .

import pandas as pd
import numpy as np

# Eliminate the records with empty treatment method
df = pd.read_excel(" Data table _25.xlsx", sheet_name=" Formulas and functions ", index_col=False)
df.dropna()
df.to_excel(" Data table _25_2.xlsx", sheet_name=" Formulas and functions ")

# Calculate the average number of days of medication corresponding to different treatment methods
df = pd.read_excel(" Data table _25.xlsx", sheet_name=" Formulas and functions ", index_col=False)
mean_M1 = 0
count_M1 = 0
mean_P1 = 0
count_P1 = 0
for i in df.index:
each_record = df.values[i]
if each_record[3] == "M1":
mean_M1 += each_record[4]
count_M1 += 1
if each_record[3] == "P1":
mean_P1 += each_record[4]
count_P1 += 1
print(" The treatment method is P1 The average days of administration were :", int(mean_P1/count_P1))
print(" The treatment method is M1 The average days of administration were :", int(mean_M1/count_M1))

Operation results and error reporting contents

Traceback (most recent call last):
File "C:\pythonProject\main.py", line 5, in
df = pd.read_excel(" Data table _25.xlsx", sheet_name=" Formulas and functions ", index_col=False)
File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\pandas\util_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\pandas\io\excel_base.py", line 457, in read_excel
io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\pandas\io\excel_base.py", line 1376, in init
ext = inspect_excel_format(
File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\pandas\io\excel_base.py", line 1250, in inspect_excel_format
with get_handle(
File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\pandas\io\common.py", line 798, in get_handle
handle = open(handle, ioargs.mode)
FileNotFoundError: [Errno 2] No such file or directory: ' Data table _25.xlsx'

What I want to achieve

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved