ankane/ruby-polars

[Question] How to display all rows of a polars dataframe on the terminal?

kojix2 opened this issue · 3 comments

kojix2 commented

Hi!

Let me ask one more question.
Is there a way to output all rows of a data frame on the terminal?

shape: (150, 5)
┌──────────────┬─────────────┬──────────────┬─────────────┬────────────────┐
│ sepal_length ┆ sepal_width ┆ petal_length ┆ petal_width ┆ species        │
│ ---          ┆ ---         ┆ ---          ┆ ---         ┆ ---            │
│ f64          ┆ f64         ┆ f64          ┆ f64         ┆ str            │
╞══════════════╪═════════════╪══════════════╪═════════════╪════════════════╡
│ 5.1          ┆ 3.5         ┆ 1.4          ┆ 0.2         ┆ Iris-setosa    │
│ 4.9          ┆ 3.0         ┆ 1.4          ┆ 0.2         ┆ Iris-setosa    │
│ 4.7          ┆ 3.2         ┆ 1.3          ┆ 0.2         ┆ Iris-setosa    │
│ 4.6          ┆ 3.1         ┆ 1.5          ┆ 0.2         ┆ Iris-setosa    │
│ …            ┆ …           ┆ …            ┆ …           ┆ …              │ <<< 👀 I want to see here. 
│ 6.3          ┆ 2.5         ┆ 5.0          ┆ 1.9         ┆ Iris-virginica │
│ 6.5          ┆ 3.0         ┆ 5.2          ┆ 2.0         ┆ Iris-virginica │
│ 6.2          ┆ 3.4         ┆ 5.4          ┆ 2.3         ┆ Iris-virginica │
│ 5.9          ┆ 3.0         ┆ 5.1          ┆ 1.8         ┆ Iris-virginica │
└──────────────┴─────────────┴──────────────┴─────────────┴────────────────┘

I looked at the code and found the following line.
https://github.com/ankane/polars-ruby/blob/5e7c1f5ab040df9a6c0d1a75729978ba46eed850/ext/polars/src/dataframe.rs#L640

Is there something like set_tbl_rows?

ankane commented

Hi @kojix2, will add the Config module as the official method, but you can use environment variables directly in the meantime:

ENV["POLARS_FMT_MAX_ROWS"] = "10000"
kojix2 commented

Thank you @ankane.

I was able to display all rows of the data frame by changing the environment variable POLARS_FMT_MAX_ROWS.
Very useful.

I am always amazed at your work to keep building libraries with new technologies like Rust.
Please take care of yourself and keep developing!

ankane commented

Thanks @kojix2!