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

fix(python): Fix _repr_html_ double-height rows (#5645) #6534

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

2-5
Copy link
Contributor

@2-5 2-5 commented Jan 28, 2023

Fixes #5645

I've only changed the CSS:

  1. removed white-space: pre - the rule causing double-height rows

  2. removed scoped from <style scoped> attribute. It was dropped, no current browser implements it - https://stackoverflow.com/a/45692033

  3. renamed .dataframe class to .pl-dataframe to prevent interactions with Pandas which also uses .dataframe. The interaction can be observed: add color: red to Polars HTML and you'll see the Pandas output change too.

  4. removed th:only-of-type rule, only-of-type is not used by Polars (only Pandas).

  5. removed tbody tr th rule, not used by Polars, possibly used by Pandas multi-index.

  6. replace descendant selector (thead tr th) with child selector (thead > tr > th) - CSS best practice

  7. removed VS Code bug workaround, and line-height: 95% rule.

Note that current Pandas styling is very similar to this PR.

Rows can be made more condensed (less vertical padding) by adding something like below. This is a visual design issue, not for me to decide.

Very condensed (no vertical padding):

.pl-dataframe > tbody > tr > td {
  padding-top: 0;
  padding-bottom: 0,
}

More condensed (less vertical padding):

.pl-dataframe > tbody > tr > td {
  padding-top: 2px;
  padding-bottom: 2px,
}

BEFORE:

polars_html_original

AFTER:

polars_html_fixed

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Jan 28, 2023
@2-5
Copy link
Contributor Author

2-5 commented Jan 28, 2023

Lint Python build failed with github connect error:

error: failed to get `arrow2` as a dependency of package `polars-core v0.26.1 (/home/runner/work/polars/polars/polars/polars-core)`
    ... which satisfies path dependency `polars-core` (locked to 0.26.1) of package `py-polars v0.15.18 (/home/runner/work/polars/polars/py-polars)`

Caused by:
  failed to load source for dependency `arrow2`

Caused by:
  Unable to update https://github.com/ritchie46/arrow2?branch=mmap_slice2#685cf49d

Caused by:
  failed to clone into: /home/runner/.cargo/git/db/arrow2-945af624853845da

Caused by:
  failed to connect to github.com: Connection timed out; class=Os (2)
make: *** [Makefile:38: clippy] Error 101
Error: Process completed with exit code 2.

Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ran this locally and it looks good to me! Thanks for the contribution.

@ritchie46 ritchie46 merged commit a08c7ba into pola-rs:master Feb 2, 2023
@alexander-beedie
Copy link
Collaborator

Very nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame & Series html repr in notebook (_repr_html)
4 participants