Rust Polars:如何显示所有列?
Rust Polars: how to show all columns?
我使用 Rust Polars 并发现使用它有点困难,因为不太确定如何显示所有列。
use polars::df;
// use macro
let df = df! [
"Column A 12345678910" => ["a", "b", "c"],
"Column B 12345678910" => [1, 2, 3],
"Column C 12345678910" => [Some(1), None, Some(3)],
"Column D 12345678910" => [Some(1), None, Some(3)],
"Column E 12345678910" => [Some(1), None, Some(3)],
"Column F 12345678910" => [1, 2, 3],
"Column G 12345678910" => [1, 2, 3],
"Column Z 12345678910" => [1, 2, 3],
"Column Ex 12345678910" => [Some(1), None, Some(3)],
"Column Fs 12345678910" => [1, 2, 3],
"Column Ga 12345678910" => [1, 2, 3],
"Column Zz 12345678910" => [1, 2, 3],
]?;
println!("{:?}", df);
输出
shape: (3, 12)
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
| Column A 12345678910 | Column B 12345678910 | Column C 12345678910 | Column D 12345678910 | ... | Column Ex 12345678910 | Column Fs 12345678910 | Column Ga 12345678910 | Column Zz 12345678910 |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| str | i32 | i32 | i32 | | i32 | i32 | i32 | i32 |
+======================+======================+======================+======================+=====+=======================+=======================+=======================+=======================+
| a | 1 | 1 | 1 | ... | 1 | 1 | 1 | 1 |
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
| b | 2 | null | null | ... | null | 2 | 2 | 2 |
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
| c | 3 | 3 | 3 | ... | 3 | 3 | 3 | 3 |
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
是否可以显示所有带有 rust polars 的列?
您可以通过将 POLARS_FMT_MAX_COLS
设置为您想要的最大列数来更改默认值。
在文档中查看更多环境变量设置:https://pola-rs.github.io/polars/polars/index.html#config-with-env-vars
我使用 Rust Polars 并发现使用它有点困难,因为不太确定如何显示所有列。
use polars::df;
// use macro
let df = df! [
"Column A 12345678910" => ["a", "b", "c"],
"Column B 12345678910" => [1, 2, 3],
"Column C 12345678910" => [Some(1), None, Some(3)],
"Column D 12345678910" => [Some(1), None, Some(3)],
"Column E 12345678910" => [Some(1), None, Some(3)],
"Column F 12345678910" => [1, 2, 3],
"Column G 12345678910" => [1, 2, 3],
"Column Z 12345678910" => [1, 2, 3],
"Column Ex 12345678910" => [Some(1), None, Some(3)],
"Column Fs 12345678910" => [1, 2, 3],
"Column Ga 12345678910" => [1, 2, 3],
"Column Zz 12345678910" => [1, 2, 3],
]?;
println!("{:?}", df);
输出
shape: (3, 12)
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
| Column A 12345678910 | Column B 12345678910 | Column C 12345678910 | Column D 12345678910 | ... | Column Ex 12345678910 | Column Fs 12345678910 | Column Ga 12345678910 | Column Zz 12345678910 |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| str | i32 | i32 | i32 | | i32 | i32 | i32 | i32 |
+======================+======================+======================+======================+=====+=======================+=======================+=======================+=======================+
| a | 1 | 1 | 1 | ... | 1 | 1 | 1 | 1 |
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
| b | 2 | null | null | ... | null | 2 | 2 | 2 |
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
| c | 3 | 3 | 3 | ... | 3 | 3 | 3 | 3 |
+----------------------+----------------------+----------------------+----------------------+-----+-----------------------+-----------------------+-----------------------+-----------------------+
是否可以显示所有带有 rust polars 的列?
您可以通过将 POLARS_FMT_MAX_COLS
设置为您想要的最大列数来更改默认值。
在文档中查看更多环境变量设置:https://pola-rs.github.io/polars/polars/index.html#config-with-env-vars