pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.24k stars 17.79k forks source link

ENH: styler.to_excel to support excel notes as implementation of tooltips #58070

Open sdementen opened 5 months ago

sdementen commented 5 months ago

Feature Type

Problem Description

I wish I could use set_tooltips in the styler to generate notes in an excel workbook (via the to_excel)

Feature Description

No real API change, but have the ExcelFormatter use the information set by styler.set_tooltips to create not on the cells with a tooltip

Alternative Solutions

No idea for an alternative except the statu quo...

Additional Context

No response

rhshadrach commented 5 months ago

Thanks for the request. The proposed behavior here seems intuitive to me, I'm supportive of this as long as the implementation is reasonable.

cc @attack68 for thoughts.

rhshadrach commented 5 months ago

One difficulty I've encountered in the past is getting the comment size correct. If you do not set the size of a long comment (at least, using xlsxwriter), the comment is very difficult to read without resizing in Excel.

attack68 commented 5 months ago

I think the implementation would not be too complicated.

The Styler Tooltips object contains a DataFrame of strings that would serve as the data to the written excel cells.

I expect that xlswriter procedure could check for the existence of a Tooltips object. If none writing to excel is unchanged and performance identical. If it exists then the yielded excel cells would have an extended routine to write the comment as provided by the tooltips string.

Not sure that Tooltips is a widely used feature, however, but if someone was willing to explore this implementation I would help review.

Dacops commented 4 months ago

Hi, this seems like an interesting issue that me and my colleague @diogomsmiranda would like to tackle. If we have any doubt about it we'll reply on this thread

Dacops commented 4 months ago

take

diogomsmiranda commented 4 months ago

take