英文:
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)
英文:
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)
答案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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论