Skip to content

DataFrame.to_html should validate that formatters has the correct length #28469

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

Closed
TomAugspurger opened this issue Sep 16, 2019 · 4 comments · Fixed by #28632
Closed

DataFrame.to_html should validate that formatters has the correct length #28469

TomAugspurger opened this issue Sep 16, 2019 · 4 comments · Fixed by #28632
Labels
Error Reporting Incorrect or improved errors from pandas good first issue IO HTML read_html, to_html, Styler.apply, Styler.applymap

Comments

@TomAugspurger
Copy link
Contributor

The length of formatters should match the number of columns

Both of these should error with a nice message.

In [2]: df = pd.DataFrame(columns=['a', 'b', 'c'])

In [3]: df.to_html(formatters=['{}'.format])


In [4]: df.to_html(formatters=['{}'.format] * 5)

Currntly In [4] succeeds, silently ignoring the bad input. In[3] values with a vague IndexError: list index out of range.

@TomAugspurger TomAugspurger added Error Reporting Incorrect or improved errors from pandas IO HTML read_html, to_html, Styler.apply, Styler.applymap good first issue labels Sep 16, 2019
@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Sep 16, 2019
@guipleite
Copy link
Contributor

Hi! Can @hugoecarl and @gabriellm1 and I work on this?

@WillAyd
Copy link
Member

WillAyd commented Sep 17, 2019

@guipleite for sure - would certainly take a PR from you all

@gabriellm1
Copy link
Contributor

So in case In[3] and In[4] the result error should be the same as formatters list not same length as Dataframe ? If so, where in the project should this be made?

@TomAugspurger
Copy link
Contributor Author

Possibly in DataFrameFormatter.__init__? Not really sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas good first issue IO HTML read_html, to_html, Styler.apply, Styler.applymap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants