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

Print empty DataFrame #1019

Merged
merged 2 commits into from
Nov 19, 2024
Merged

Print empty DataFrame #1019

merged 2 commits into from
Nov 19, 2024

Conversation

billylanchantin
Copy link
Contributor

@billylanchantin billylanchantin commented Nov 18, 2024

We currently raise if you try to print a DataFrame with no rows or columns:

iex(1)> df = Explorer.DataFrame.new([])
#Explorer.DataFrame<
  Polars[0 x 0]
>

iex(2)> Explorer.DataFrame.print(df)
** (ArithmeticError) bad argument in arithmetic expression
    (table_rex 4.0.0) lib/table_rex/renderer/text.ex:378: TableRex.Renderer.Text.max_dimensions/1
    (table_rex 4.0.0) lib/table_rex/renderer/text.ex:56: TableRex.Renderer.Text.render/2
    (table_rex 4.0.0) lib/table_rex/table.ex:280: TableRex.Table.render!/2
    (explorer 0.11.0-dev) lib/explorer/data_frame.ex:5976: Explorer.DataFrame.print/2
    iex:2: (file)

This PR fixes that with a default print string:

...

iex(2)> Explorer.DataFrame.print(df)
+-------------------------------------------+
| Explorer DataFrame: [rows: 0, columns: 0] |
+-------------------------------------------+

:ok

I also documented the option to the print function.

@billylanchantin billylanchantin merged commit a37eb2b into main Nov 19, 2024
3 checks passed
@billylanchantin billylanchantin deleted the bl-print-empty-df branch November 19, 2024 01:28
@billylanchantin
Copy link
Contributor Author

This is part of fixing #1014

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