Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pd.read\u excel数据删除错误_Python_Pandas_File - Fatal编程技术网

Python pd.read\u excel数据删除错误

Python pd.read\u excel数据删除错误,python,pandas,file,Python,Pandas,File,我正在尝试将数据从excel读取到pandas。我从api获取的文件未保存(对该文件的访问需要特殊权限,因此我不想保存)。当我试图从文件中读取excel时 我得到了错误 当我在文件中输入路径时,一切正常 有没有一种方法可以通过pandas读取excel而不保存它并输入路径?缺少的部分是打开的'rb' with open('path_to_file', 'rb') as file: re = pd.read_excel(file) 将文件视为二进制文件。想法取自尝试以字节形式读取文件:以

我正在尝试将数据从excel读取到pandas。我从api获取的文件未保存(对该文件的访问需要特殊权限,因此我不想保存)。当我试图从文件中读取excel时

我得到了错误

当我在文件中输入路径时,一切正常


有没有一种方法可以通过pandas读取excel而不保存它并输入路径?

缺少的部分是打开的
'rb'

with open('path_to_file', 'rb') as file:
    re = pd.read_excel(file)

将文件视为二进制文件。想法取自

尝试以字节形式读取文件:
以open('path_to_file','rb')形式读取文件
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position
10: invalid start byte
re = pd.read_excel('path-to-exactly-the-same-file')
with open('path_to_file', 'rb') as file:
    re = pd.read_excel(file)