Polars / Python 限制打印表输出行数

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

有谁知道为什么 Polars (或者可能是我的 pycharm 设置或 python 调试器)限制输出中的行数?这让我发疯。

这是我正在运行的极坐标代码,但我确实怀疑它不是特定于极坐标的,因为谷歌上没有太多(chatgpt 说它的信息太旧了哈哈)。

import polars as pl

df = pl.scan_parquet('/path/to/file.parquet')
result_df =(
        df
        .filter(pl.col("condition_category") == 'unknown')
        .groupby("type")
        .agg(
            [
                pl.col("type").count().alias("counts"),
            ]
        )
    ).collect()
print(result_df)

python pandas debugging python-polars truncated
1个回答
3
投票

看起来以下内容会起作用。感谢@wayoshi 分享this。我会说默认值太保守了!

with pl.Config(tbl_rows=1000):
    print(result_df)

或者如果您不想管理上下文,请将其放在脚本的顶部。

import polars as pl

# Configure Polars 
cfg = pl.Config()
cfg.set_tbl_rows(2000)
© www.soinside.com 2019 - 2024. All rights reserved.