FutureWarning:向“read_excel”传递字节已被弃用,并将在未来版本中删除 pd.read_excelblob_data.readall(), engine='openpyxl'

问题描述 投票:0回答:1

错误:未来警告:将字节传递给“read_excel”已被弃用,并将在未来版本中删除。要读取字节字符串,请将其包装在

B ytesIO
对象中。 df = pd.read_excel(blob_data.readall(), engine='openpyxl')

我收到此错误,还有其他选项可以从 Excel 文件读取数据吗?

我想要这个 openpyxl 问题的替代解决方案或库支持!

python openpyxl
1个回答
0
投票

blob_data.readall()
是字节,不推荐将字节传递给
pandas.read_excel

您可以使用

BytesIO
:

传递类似文件的对象而不是字节
from io import BytesIO
import pandas as pd

df = pd.read_excel(BytesIO(blob_data.readall()), engine='openpyxl')
© www.soinside.com 2019 - 2024. All rights reserved.