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

huangapple go评论60阅读模式
英文:

Polars / Python Limits Number of Printed Table Output Rows

问题

I understand your request. Here's the translated content:

有人知道为什么 Polars(或者可能是我的 PyCharm 设置或 Python 调试器)限制了输出中的行数吗?这让我很烦恼。

这是我正在运行的 Polars 代码,但我怀疑它与 Polars 无关,因为在谷歌上几乎找不到相关信息(而 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)

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

英文:

Does anyone know why polars (or maybe my pycharm setup or python debugger) limits the number of rows in the output? This drives me nuts.

Here is the polars code i am running but I do suspect its not polars specific as there isnt much out there on google (and chatgpt said its info is too old haha).

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)

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

答案1

得分: 2

以下部分已翻译:

"Looks like the following will work. Thanks to @wayoshi for sharing this. I will say that the defaults are way too conservative!

    cfg.set_tbl_rows(1000)
    print(result_df)

or throw this at the top of your script if you prefer to not manage contexts.

import polars as pl

# Configure Polars 
cfg = pl.Config()
cfg.set_tbl_rows(2000)
```"

[1]: https://pola-rs.github.io/polars/py-polars/html/reference/config.html

<details>
<summary>英文:</summary>

Looks like the following will work. Thanks to @wayoshi for sharing [this][1]. I will say that the defaults are way too conservative!

with pl.Config() as cfg:
cfg.set_tbl_rows(1000)
print(result_df)


or throw this at the top of your script if you prefer to not manage contexts.

import polars as pl

Configure Polars

cfg = pl.Config()
cfg.set_tbl_rows(2000)



  [1]: https://pola-rs.github.io/polars/py-polars/html/reference/config.html

</details>



huangapple
  • 本文由 发表于 2023年4月17日 21:46:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76035847.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定