Skip to content

DOC: formatters in DataFrame.to_html cannot be list #2520

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
craustin opened this issue Dec 13, 2012 · 4 comments
Closed

DOC: formatters in DataFrame.to_html cannot be list #2520

craustin opened this issue Dec 13, 2012 · 4 comments
Milestone

Comments

@craustin
Copy link

pandas\core\frame.pyc in to_html(self, buf, columns, col_space, colSpace, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, force_unicode, bold_rows, classes)
   1537                                            header=header, index=index,
   1538                                            bold_rows=bold_rows)
-> 1539         formatter.to_html(classes=classes)
   1540
   1541         if buf is None:

pandas\core\format.pyc in to_html(self, classes)
    374         """
    375         html_renderer = HTMLFormatter(self, classes=classes)
--> 376         html_renderer.write_result(self.buf)
    377
    378     def _get_formatted_column_labels(self):

pandas\core\format.pyc in write_result(self, buf)
    549             indent += self.indent_delta
    550             indent = self._write_header(indent)
--> 551             indent = self._write_body(indent)
    552
    553         self.write('</table>', indent)

pandas\core\format.pyc in _write_body(self, indent)
    635         fmt_values = {}
    636         for i in range(len(self.columns)):
--> 637             fmt_values[i] = self.fmt._format_col(i)
    638
    639         # write values

pandas\core\format.pyc in _format_col(self, i)
    363     def _format_col(self, i):
    364         col = self.columns[i]
--> 365         formatter = self.formatters.get(col)
    366         return format_array(self.frame.icol(i).values, formatter,
    367                             float_format=self.float_format,

AttributeError: 'list' object has no attribute 'get'
@wesm
Copy link
Member

wesm commented Dec 13, 2012

Are you expecting to pass a list of same length as the columns?

@craustin
Copy link
Author

The doc says I can pass a list. It's unclear, but maybe it should take a list as long as the number of cells to be printed. This would be the (optional) index + the number of columns.

@wesm
Copy link
Member

wesm commented Dec 13, 2012

My read is that it should be of list having equal length to the DataFrame's columns. The code is designed (right now, at least) to use at most one formatter function per column

@craustin
Copy link
Author

Sounds good. Only issue then is that right now that causes the exception above. Additionally, might want to have a way to format the index/

@wesm wesm closed this as completed in f198721 Dec 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants