I have a Polars DataFrame
with a list column. I want to control how many elements of a pl.List
column are printed.
I've tried pl.pl.Config.set_fmt_str_lengths()
but this only restricts the number of elements if set to a small value, it doesn't show more elements for a large value.
I'm working in Jupyterlab but I think it's a general issue.
import polars as pl
N = 5
df = (
pl.DataFrame({
"id": range(N)
})
.with_row_index("value")
.rolling(
"id", period=f"{N}i"
)
.agg(
pl.col("value")
)
)
shape: (5, 2)
┌─────┬─────────────┐
│ id ┆ value │
│ --- ┆ --- │
│ i64 ┆ list[u32] │
╞═════╪═════════════╡
│ 0 ┆ [0] │
│ 1 ┆ [0, 1] │
│ 2 ┆ [0, 1, 2] │
│ 3 ┆ [0, 1, … 3] │
│ 4 ┆ [0, 1, … 4] │
└─────┴─────────────┘
pl.Config.set_tbl_rows(100)
And more generally, I would try looking at dir(pl.Config)
Release 0.19.9 added a new config setting to control how many List items are printed.
import polars as pl
pl.Config.set_fmt_table_cell_list_len(10)
pl.DataFrame({
"my_lists": [range(n) for n in range(7)]
})
Output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With