import pandas as pd
file = 'C:/Users/user/Desktop/test/Excel file.xlsx'
find_string = "John"
x = pd.read_excel(file, sheet_name = 'Sheet2')
使用此代码,我想定义一个无需使用任何外部库即可从任何文件中删除特定行的函数。但这会引发以下错误:
file = 'C:/Users/user/Desktop/test/Excel file.xlsx'
df = pd.read_excel(file, sheet_name = 'sheet2')
new_df = df[df['First Name'].str.contains('John')][['Last Name']].reset_index(drop = True)
我已经用West
关闭文件了,怎么会出现此错误?