小编Rah*_*hil的帖子

将 pandas 数据帧转换为 Polars 数据帧时出错(pyarrow.lib.ArrowTypeError:预期字节,得到“int”对象)

我正在将 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 …

dataframe pandas python-polars

7
推荐指数
1
解决办法
4万
查看次数

如何在 Polars 数据框中打开 Excel 文件?

我是一个 python pandas 用户,但最近发现了关于 Polars 数据框,它看起来很有前途并且速度非常快。我无法找到在极坐标中打开 Excel 文件的方法。Polars 很高兴阅读csvjson等,但不是 excel。

我是 pandas 中 excel 文件的广泛用户,我想尝试使用极坐标。我在 Excel 中有很多工作表,pandas 自动读取。我怎样才能对极地做同样的事情?

我缺少什么?

python excel dataframe pandas python-polars

4
推荐指数
1
解决办法
7305
查看次数

标签 统计

dataframe ×2

pandas ×2

python-polars ×2

excel ×1

python ×1