Polars chops some text instead of showing all text like the following
| Link | Name |
|---|---|
| https://… | name1 |
| https://… | name2 |
I want Polars to show all text of Link Col
How can I do that?
Advertisement
Answer
You should change pl.Config() settings – pl.Config.set_fmt_str_lengths(n) (see doc)
import polars as pl
pl.Config.set_fmt_str_lengths(50)
df = pl.DataFrame({"n": [1], "link": ["https://stackoverflow.com/long/link"]})
print(df)
┌─────┬─────────────────────────────────────┐ │ n ┆ link │ │ --- ┆ --- │ │ i64 ┆ str │ ╞═════╪═════════════════════════════════════╡ │ 1 ┆ https://stackoverflow.com/long/link │ └─────┴─────────────────────────────────────┘
If you just want to check, how new table view looks like, you can use with pl.Config() (this will not affect to next table’s printings). Also pl.Config.set_tbl_width_chars(n) allows to set total width of table. For instance:
with pl.Config() as cfg:
cfg.set_tbl_width_chars(15) # total width of table
cfg.set_fmt_str_lengths(50)
print(df)
┌─────┬───────┐ │ n ┆ link │ │ --- ┆ --- │ │ i64 ┆ str │ ╞═════╪═══════╡ │ 1 ┆ https │ │ ┆ ://st │ │ ┆ ackov │ │ ┆ erflo │ │ ┆ w.com │ │ ┆ /long │ │ ┆ /link │ └─────┴───────┘