我正在将 pandas 数据帧转换为 Polars 数据帧,但 pyarrow 抛出错误。
我的代码:
import polars as pl
import pandas as pd
if __name__ == "__main__":
with open(r"test.xlsx", "rb") as f:
excelfile = f.read()
excelfile = pd.ExcelFile(excelfile)
sheetnames = excelfile.sheet_names
df = pd.concat(
[
pd.read_excel(
excelfile, sheet_name=x, header=0)
for x in sheetnames
], axis=0)
df_pl = pl.from_pandas(df)
Run Code Online (Sandbox Code Playgroud)
错误:
File "pyarrow\array.pxi", line 312, in pyarrow.lib.array
File "pyarrow\array.pxi", line 83, in pyarrow.lib._ndarray_to_array
File "pyarrow\error.pxi", line 122, in pyarrow.lib.check_status
pyarrow.lib.ArrowTypeError: Expected bytes, got a 'int' object
我尝试将 pandas dataframe …
我是一个 python pandas 用户,但最近发现了关于 Polars 数据框,它看起来很有前途并且速度非常快。我无法找到在极坐标中打开 Excel 文件的方法。Polars 很高兴阅读csv、json等,但不是 excel。
我是 pandas 中 excel 文件的广泛用户,我想尝试使用极坐标。我在 Excel 中有很多工作表,pandas 自动读取。我怎样才能对极地做同样的事情?
我缺少什么?