dautil.report

This module contains reporting utilities.

class dautil.report.DFBuilder(cols, *args)

Builds a pandas DataFrame, by updating a dict incrementally.

The actual DataFrame is built at the end of the build process.

Variables:
  • columns – The columns of the DataFrame.
  • df – The DataFrame.
build(index=None)

Builds a pandas DataFrame from an internal dict.

Parameters:index – A list representing the DataFrame index.
Returns:A pandas DataFrame.
row(row)

Adds a row to the pandas DataFrame

Parameters:row – A list of values to add.
Returns:A table-like dict.
>>> from dautil import report
>>> builder = report.DFBuilder(['A', 'B'])
>>> row = list(range(2))
>>> builder.row(row)
{'B': [1], 'A': [0]}
>>> builder.df
{'B': [1], 'A': [0]}
class dautil.report.HTMLBuilder

Builds a HTML string.

Variables:html – A string representing HTML.
add(text)

Adds arbitrary html.

Parameters:txt – The html to add.
>>> from dautil import report
>>> hb = report.HTMLBuilder()
>>> hb.add('<p>42</p>')
>>> hb.html
'<div><p>42</p></div><br/>'
add_df(df, index=False, *args, **kwargs)

Converts a pandas DataFrame to HTML and adds it.

Parameters:
  • df – A pandas DataFrame.
  • index – Boolean indicating whether to display the index.
h1(heading)

Adds a first level heading.

Parameters:heading – The text of the heading.
h2(heading)

Adds a second level heading.

Parameters:heading – The text of the heading.
>>> from dautil import report
>>> hb = report.HTMLBuilder()
>>> hb.h2('Heading 2')
>>> hb.html
'<h2 style="color:gray;">Heading 2</h2><br/>'
watermark()

Adds a watermark containing versions of detected software libraries.

Returns:The HTML of the watermark.
class dautil.report.RSTWriter

Writes a reStructured text file.

Variables:rst – A string representing reStructured text.
add(txt)

Adds arbitrary text.

Parameters:txt – The text to add.
divider()

Adds a divider.

h1(txt)

Adds a first level heading.

Parameters:txt – The text of the heading.
write(fname)

Writes to a file.

Parameters:fname – The name of the file.
dautil.report.map_grid(a, b, cols, func, *args, **kwargs)

Apply a function to the cells of a grid.

Parameters:
  • a – One of two arrays used to form the grid.
  • b – One of two arrays used to form the grid.
  • cols – A list of column names.
  • func – Function to apply.
Returns:

A pandas DataFrame containing the result.

Previous topic

dautil.plotting

Next topic

dautil.stats

This Page