-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Styler column and row styles #35607
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not sure we want to be adding api like this, rather can you use a keyword arg to .set_table_styles?
One of the problems with set_table_styles is that it is a one-time function. Any repeated activity will simply overwrite previous styling, so the user is required to custom build up all style functions and then add at the end. No column argument will avoid this complexity. One of the functions in this commit is literally just an extension, I could modify the code to accept an argument
This would work for a single column and could be integrated into a user loop over different columns. ##Discussion But since the purpose of Styler is to provide display capability, and it currently does not offer the ability to directly attach named CSS classes to cells, or rows or columns, I do not understand why you would shy away from providing the functionality to directly style a column in the most efficient manner. This can be extended to rows later. It seems to be quite a basic functionality that has been requested in other instances that is easily crafted with current tools, and the direct purpose of styling columns is quite an easy user functionality to grasp??? |
I had a think on your comment @jreback. The addition of multiple arguments to the It also had the advantage of being able to address row styling at the same time as column styling. Tests and examples have been amended. |
f67f6bb
to
ed50068
Compare
conversations/changes resolved or comments added, all green, @jreback .. ping. |
Seems good to me.
…On Fri, Aug 14, 2020 at 3:51 AM attack68 ***@***.***> wrote:
conversations/changes resolved or comments added, all green, @jreback
<https://github.com/jreback> .. ping.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#35607 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKAOIVAMEQX334OFN7337DSAT3KBANCNFSM4PXTRRDA>
.
|
d78f198
to
25a1d7d
Compare
25a1d7d
to
08fc864
Compare
@jreback reviving this after a couple of weeks, all green, and changes requested implemented. |
…le_enh # Conflicts: # doc/source/whatsnew/v1.2.0.rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restarted the failed build.
…le_enh # Conflicts: # pandas/tests/io/formats/test_style.py
@jreback keeping this one alive... |
can you merge master. I understand what I think it might be better to use |
This is a strange one. The problem with In i) Currently,
FYI part of the design structure I think was to maintain a self contained object as a property: |
…le_enh # Conflicts: # doc/source/whatsnew/v1.2.0.rst # pandas/tests/io/formats/test_style.py
Fixed the merge conflict in the whatsnew. I think this was OK last I looked. |
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
…le_enh # Conflicts: # doc/source/user_guide/style.ipynb # doc/source/whatsnew/v1.2.0.rst
I merged master into this again. Only outstanding issue is acceptance, or not, of the I stand by this, rather than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok small comment, pls add a whatsnew note in 1.2, merge master and ping on green.
@@ -987,34 +987,95 @@ def set_caption(self, caption: str) -> "Styler": | |||
self.caption = caption | |||
return self | |||
|
|||
def set_table_styles(self, table_styles) -> "Styler": | |||
def set_table_styles(self, table_styles, axis=0, overwrite=True) -> "Styler": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you type table_styles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried adding the following to func def, but it got errors, I don't know my way around mypy and this seems slightly more complicated than normal with the multiple acceptable input types and programming logic:
table_styles: Union[
List[Dict[str, Union[str, List[Tuple[str, str]]]]],
Dict[
Union[str, Tuple[Any, ...]],
List[Dict[str, Union[str, List[Tuple[str, str]]]]],
],
] = []
So I reverted the attempt.
However, all green, pinging @jreback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok if you can follow and make this much more intuitive (e.g. define aliases here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it is not-trivial to actually construct this union
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this is fine. pls followup with a typing PR as the table_styles is very confusing w/o it
@@ -987,34 +987,95 @@ def set_caption(self, caption: str) -> "Styler": | |||
self.caption = caption | |||
return self | |||
|
|||
def set_table_styles(self, table_styles) -> "Styler": | |||
def set_table_styles(self, table_styles, axis=0, overwrite=True) -> "Styler": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok if you can follow and make this much more intuitive (e.g. define aliases here)
@@ -987,34 +987,95 @@ def set_caption(self, caption: str) -> "Styler": | |||
self.caption = caption | |||
return self | |||
|
|||
def set_table_styles(self, table_styles) -> "Styler": | |||
def set_table_styles(self, table_styles, axis=0, overwrite=True) -> "Styler": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it is not-trivial to actually construct this union
thanks @attack68 |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff