Comments (1)
Let's say we have a DataFrame as you describe, with long column names and short values:
df = pl.DataFrame({"This is a really long column name with short values": [1],
"This is a second really long column name with short values": [2],
"This is a third really long column name with short values": [3],
"This is a fourth really long column name with short values": [4],
"This is a fifth really long column name with short values": [5],
"This is a sixth really long column name with short values": [6],
"This is a seventh really long column name with short values": [7],
"This is an eight really long column name with short values": [8],
"This is a ninth really long column name with short values": [9]})
With the default settings, df
is printed as follows:
print(df)
shape: (1, 9)
┌───────────┬───────────┬───────────┬───────────┬───┬───────────┬───────────┬───────────┬──────────┐
│ This is a ┆ This is a ┆ This is a ┆ This is a ┆ … ┆ This is a ┆ This is a ┆ This is ┆ This is │
│ really ┆ second ┆ third ┆ fourth ┆ ┆ sixth ┆ seventh ┆ an eight ┆ a ninth │
│ long ┆ really ┆ really ┆ really ┆ ┆ really ┆ really ┆ really ┆ really │
│ column n… ┆ long c… ┆ long co… ┆ long c… ┆ ┆ long co… ┆ long … ┆ long c… ┆ long co… │
│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 ┆ i64 ┆ ┆ i64 ┆ i64 ┆ i64 ┆ i64 │
╞═══════════╪═══════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪═══════════╪══════════╡
│ 1 ┆ 2 ┆ 3 ┆ 4 ┆ … ┆ 6 ┆ 7 ┆ 8 ┆ 9 │
└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘
To show all columns:
with pl.Config(set_tbl_cols=-1):
print(df)
shape: (1, 9)
┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
│ This is ┆ This is ┆ This is ┆ This is ┆ This is ┆ This is ┆ This is ┆ This is ┆ This is │
│ a really ┆ a second ┆ a third ┆ a fourth ┆ a fifth ┆ a sixth ┆ a ┆ an eight ┆ a ninth │
│ long ┆ really ┆ really ┆ really ┆ really ┆ really ┆ seventh ┆ really ┆ really │
│ column ┆ long c… ┆ long co… ┆ long c… ┆ long co… ┆ long co… ┆ really ┆ long c… ┆ long co… │
│ n… ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ long … ┆ --- ┆ --- │
│ --- ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ --- ┆ i64 ┆ i64 │
│ i64 ┆ ┆ ┆ ┆ ┆ ┆ i64 ┆ ┆ │
╞══════════╪══════════╪══════════╪══════════╪══════════╪══════════╪══════════╪══════════╪══════════╡
│ 1 ┆ 2 ┆ 3 ┆ 4 ┆ 5 ┆ 6 ┆ 7 ┆ 8 ┆ 9 │
└──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┘
To increase the width of the frame but constrain the width of the columns:
with pl.Config(set_tbl_cols=-1, set_fmt_str_lengths=20, set_tbl_width_chars=1000):
print(df)
shape: (1, 9)
┌───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│ This is a really lon… ┆ This is a second rea… ┆ This is a third real… ┆ This is a fourth rea… ┆ This is a fifth real… ┆ This is a sixth real… ┆ This is a seventh re… ┆ This is an eight rea… ┆ This is a ninth real… │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 │
╞═══════════════════════╪═══════════════════════╪═══════════════════════╪═══════════════════════╪═══════════════════════╪═══════════════════════╪═══════════════════════╪═══════════════════════╪═══════════════════════╡
│ 1 ┆ 2 ┆ 3 ┆ 4 ┆ 5 ┆ 6 ┆ 7 ┆ 8 ┆ 9 │
└───────────────────────┴───────────────────────┴───────────────────────┴───────────────────────┴───────────────────────┴───────────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘
To me, it seems that these options are sufficient but perhaps I'm missing something.
Could you please clarify what you mean with "to be the minimum width feasible" ? What would the DataFrame look like if you were to print it by setting the option tbl_max_col_width_chars
you propose?
from polars.
Related Issues (20)
- Big integer error HOT 1
- Add a `newline` parameter to `read_csv` HOT 2
- `sort_by` + `struct` + `exclude` index out of bounds PanicException
- CSV Downloads Fail for ADLS Gen2 with Azure CLI Authentication HOT 2
- Panic on datetime column min() HOT 1
- High memory usage after `collect()` despite using `limit(1)`
- Conda package outdated HOT 1
- DateFrame.describe() reports datetime as str HOT 2
- pl.list,len() - pl.list,len() always returning u32 no matter the results HOT 1
- [FEA]: Allow specifying null location in `set_sorted`
- Expose the individual parameters from fastexcel.load_sheet in pl.read_excel HOT 1
- Provide native and fast Series slice assignment (currently slower than Pandas) HOT 6
- Supporting multidimensional array style operations, by specifying metadata columns
- struct field access returns incorrect values HOT 3
- pl.struct with no arguments triggers a panic
- Multiple expr.head(n).max()/min()/etc operations in with_columns causing ShapeError
- Add `repeat` and `tile` for Series/Expr
- `SchemaFieldNotFoundError` when chaining `select` and `collect`
- Series is ignoring the dtype argument, series.to_numpy() dtype depends on values passed
- Problem filtering categorical string columns with lazy frame and scan_parquet
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polars.