-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
ENH: Enhance printing options for Styler
: head
and tail
?
#42533
Comments
Interesting idea. Do comment on the PR or further if you have any good ideas.
Nope don't want to add kwargs where they are not relevant to the function, but more add kwargs to rendering methods, or add to styler.options namespace. |
To be more precise, I like it when I call the DataFrame as the last line of code in a Colab cell and only the first 5 and last 5 rows are rendered. I was thinking something along that idea. It would be nice to be able to call |
@dennymarcels please comment on #45176 |
Hi @dennymarcels , did you have a look at issue #45176 if it has solved the issue you've been having? |
It's frustrating that max_rows can not be applied to a stylized dataframe. |
To deal with this for now, I just implemented this utility function in my code: def _truncate_dataframe(df, max_rows):
return pd.concat([df.head(max_rows//2), df.tail(max_rows//2)]) |
The "stylized dataframe" discussed in this thread is actually a |
Thanks @attack68 for the fast response. That did indeed help me, but there is still a nuance issue of the aesthetics of the truncation. I would like to see the head and tail of the dataframe rather than just the head as was pointed out by @dennymarcels in this thread. Here is my example: import pandas as pd
import panel as pn
pd.set_option('styler.render.max_rows', 5)
df = pd.DataFrame(list(range(20)))
# Define CSS style for the sapphire color on column 'A' header
styles = [
{'selector': 'th.col_heading.level0.col0',
'props': [('background-color', 'blue'), ('color', 'white')]}
]
# Apply the style to the DataFrame
styled_df = df.style.set_table_styles(styles, overwrite=False)
styled_df |
|
I don't think the API for Will close this issue and relabel the title for anyone searching for similar. |
Styler
: head
and tail
?
Is your feature request related to a problem?
More like an improvement.
Describe the solution you'd like
I just started playing around with pandas styling, and I noticed there is no way to print only the head and/or tail of a stylized DataFrame. It would be awesome if the styling could be applied to the whole df but then we could print only selected rows, like head and/or tail.
API breaking implications
I guess there could be a parameter passed to methods such as
bar
, or a new method to be appended to the end of a call.Describe alternatives you've considered
I can apply the style to a slice of a DataFrame but then the styling function is applied to this slice only. What if I want to highlight_max to the whole df but print head/tail only?
The text was updated successfully, but these errors were encountered: