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

add class=„pandas-empty“ to NaN-cells’ HTML #7338

Closed
wants to merge 1 commit into from

Conversation

hmeine
Copy link

@hmeine hmeine commented Jun 4, 2014

This PR is related to #5330, but is much simpler. There is no new API, this just allows styling empty cells using CSS, e.g. using

  td.pandas-empty { color: #eee }

to de-emphasize, or

  td.pandas-empty { background-color: yellow }

to let empty cells stand out.

This allows to do CSS styling, e.g. using
  td.pandas-empty { color: #eee }
to de-emphasize, or
  td.pandas-empty { background-color: yellow }
to let empty cells stand out.
@jreback
Copy link
Contributor

jreback commented Jun 4, 2014

@cpcloud @TomAugspurger ?

@hmeine
Copy link
Author

hmeine commented Jun 5, 2014

I should mention that I do see a weakness in the condition (testing the formatted contents against self.fmt.na_rep). However, currently the design seems to make it very hard to do better; I tried implementing this before and failed, and found this simple "solution" in the above-mentioned PR #5330.
Although it is not very clean, I personally feel that currently, it is an appropriate approximation (for testing the raw value against NaN).

@jreback
Copy link
Contributor

jreback commented Jun 5, 2014

@hmeine I see what you want to do here. I think we are looking for a more general soln (w/o too much refactoring / and no API breaking).Their are some ideas/suggestions in those linked threads. Just need someone to try an implementation.

@hmeine
Copy link
Author

hmeine commented Jun 5, 2014

I see, but I would say those are complementary goals. Marking empty cells (and index/column headers, cf. #6488) would be totally non-invasive and scratch obvious itches. The more general solution would be far more capable, but the above allows today to add CSS styling e.g. in IPython notebooks (which I am using daily).

@cpcloud
Copy link
Member

cpcloud commented Jun 5, 2014

@y-p created an excellent base from which to start, in #5763

check out this notebook (from that PR): http://nbviewer.ipython.org/github/pydata/pandas/blob/8c4f9571c08d5122f1d9e40c43dadab8b6f10bf5/pandas_HTML_styling.ipynb

in #3190 you can see all the linked issues and how many times people have requested little additions or wished pandas did some formatting thing slightly different. i totally get where you're coming from, but i think that most of the legwork was done by @y-p and we should take advantage of it rather than going for the needs of "today". if we make this change we have to support it for the foreseeable future. personally, i'd rather support an addition that is more general.

@jreback
Copy link
Contributor

jreback commented Jun 5, 2014

👍 on using the soln @cpcloud just pointed, its way more general, not that hard, and almost done. IIRC just needs some tests. Would be willing to put this in once integrated on an experimental basis. Maybe under core.html namespace (so can add stylers in the future)

@jreback
Copy link
Contributor

jreback commented Jun 5, 2014

@cpcloud the actual PR is at #5763

@cpcloud
Copy link
Member

cpcloud commented Jun 5, 2014

yep my bad thx for correcting

@cpcloud
Copy link
Member

cpcloud commented Jun 5, 2014

was gh autocomplete + enter :/

@hmeine
Copy link
Author

hmeine commented Jun 5, 2014

Ah, now I see that PR #5763 is actuallly much closer to what I proposed here than the template engine proposed in PR #3190. Then, I understand why you would rather see the generic solution. Unfortunately, I cannot help with testing ATM.

I think this PR can then be closed.

@hmeine hmeine closed this Jun 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO HTML read_html, to_html, Styler.apply, Styler.applymap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants