简体   繁体   中英

Pandas.read_excel from filepath

I'm having some problems opening an excel file from outside the directory in pandas.read_excel

import pandas as pd
filepath:"C:\\...\\Worksheet.xlsx"
dataframe=pd.read_excel(filepath)

NameError: name 'filepath' is not defined

What is going on? How can I solve this?

In addition to replacing : with = , you may also need to add r before the file path in order for python to read the raw file path. For example you can try:

filepath = r'C:\\...\\Worksheet.xlsx'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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