Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use to incidate there are hidden rows #1064

Merged
merged 2 commits into from
Feb 10, 2025
Merged

Conversation

billylanchantin
Copy link
Member

In discord we chatted about using to indicate that there are hidden rows. This PR does that, but I ended up doing a few other things while I was at it.

This PR does:

  1. Adds a row of to indicate there are hidden rows. Includes a new option limit_dots: :bottom | :split to specify how to do this.
  2. Drops the row separators when they aren't needed (see below).
  3. Allows you to pass through valid options to TableRex.render!/2. This gives you a little more flexibility in case you don't like the defaults.

Example

Explorer.Datasets.iris() |> Explorer.DataFrame.print()

Before:

+-----------------------------------------------------------------------+
|              Explorer DataFrame: [rows: 150, columns: 5]              |
+--------------+-------------+--------------+-------------+-------------+
| sepal_length | sepal_width | petal_length | petal_width |   species   |
|    <f64>     |    <f64>    |    <f64>     |    <f64>    |  <string>   |
+==============+=============+==============+=============+=============+
| 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 |
+--------------+-------------+--------------+-------------+-------------+
| 5.0          | 3.6         | 1.4          | 0.2         | Iris-setosa |
+--------------+-------------+--------------+-------------+-------------+

After:

iex> Explorer.Datasets.iris() |> Explorer.DataFrame.print()
+--------------------------------------------------------------------------+
|               Explorer DataFrame: [rows: 150, columns: 5]                |
+--------------+-------------+--------------+-------------+----------------+
| sepal_length | sepal_width | petal_length | petal_width |    species     |
|    <f64>     |    <f64>    |    <f64>     |    <f64>    |    <string>    |
+==============+=============+==============+=============+================+
| 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    |
| …            | …           | …            | …           | …              |
| 6.2          | 3.4         | 5.4          | 2.3         | Iris-virginica |
| 5.9          | 3.0         | 5.1          | 1.8         | Iris-virginica |
+--------------+-------------+--------------+-------------+----------------+

Row separators

The row separators have bothered me for a while. They effectively double the vertical size of the printed dataframe. But they're only necessary when there are multi-line cells.

With this PR, I choose to only include row separators when there's a "composite" dtype (list or struct). IMO this should cover most cases where the extra row separator is beneficial in a predictable way.

Another way to do it is to detect the presence of multi-line cells. There are tradeoffs to both approaches.

I'm also happy to scale this PR back to just the part.

@billylanchantin billylanchantin merged commit 59a08ec into main Feb 10, 2025
3 checks passed
@billylanchantin billylanchantin deleted the bl-print-dots branch February 10, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants