prettypandas package¶
-
class
prettypandas.PrettyPandas(data, summary_rows=None, summary_cols=None, formatters=None, *args, **kwargs)¶ Bases:
objectParameters: - data – DataFrame.
- summary_rows – list of Aggregate objects to be appended as a summary.
- summary_cols – list of Aggregate objects to be appended as a summary.
- formatters – List of Formatter objects to format.
-
as_currency(currency=u'USD', locale=Locale('en_US'), *args, **kwargs)¶ Format subset as currency
Parameters: - currency – Currency
- locale – Babel locale for currency formatting
- subset – Pandas subset
-
as_percent(precision=2, *args, **kwargs)¶ Format subset as percentages
Parameters: - precision – Decimal precision
- subset – Pandas subset
-
as_unit(unit, location=u'suffix', *args, **kwargs)¶ Format subset as with units
Parameters: - unit – string to use as unit
- location – prefix or suffix
- subset – Pandas subset
-
average(title=u'Average', **kwargs)¶ Add a mean summary to this table.
Parameters: title – Title to be displayed.
-
frame¶ Add summaries and convert back to DataFrame
-
max(title=u'Maximum', **kwargs)¶ Add a maximum summary to this table.
Parameters: title – Title to be displayed.
-
median(title=u'Median', **kwargs)¶ Add a median summary to this table.
Parameters: title – Title to be displayed.
-
min(title=u'Minimum', **kwargs)¶ Add a minimum summary to this table.
Parameters: title – Title to be displayed.
-
multi_summary(funcs, titles, axis=0, *args, **kwargs)¶
-
render()¶
-
style¶ Add summaries and convert to Pandas Styler
-
summary(func=<operator.methodcaller object>, title=u'Total', axis=0, subset=None, *args, **kwargs)¶ Add multiple summary rows or columns to the dataframe.
Parameters: - func – function to be used for a summary.
- titles – Title for this summary column.
- axis – Same as numpy and pandas axis argument. A value of None will cause the summary to be applied to both rows and columns.
- args – Positional arguments passed to all the functions.
- kwargs – Keyword arguments passed to all the functions.
The results of summary can be chained together.
-
to_frame()¶ Add summaries and convert back to DataFrame
-
total(title=u'Total', **kwargs)¶ Add a total summary to this table.
Parameters: title – Title to be displayed.
-
prettypandas.as_currency(currency='USD', locale=Locale('en_US'))¶
-
prettypandas.as_percent(precision=2, **kwargs)¶ Convert number to percentage string.
Parameters: - v – numerical value to be converted
- precision – int decimal places to round to
-
prettypandas.as_unit(unit, precision=2, location='suffix')¶ Convert value to unit.
Parameters: - v – numerical value
- unit – string of unit
- precision – int decimal places to round to
- location – ‘prefix’ or ‘suffix’ representing where the currency symbol falls relative to the value